NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
RE: port-hp300/50852: src/sys/arch/hp300/stand/common/ite.c:239: bad expression
The following reply was made to PR port-hp300/50852; it has been noted by GNATS.
From: David Binderman <dcb314%hotmail.com@localhost>
To: "gnats-bugs%NetBSD.org@localhost" <gnats-bugs%netbsd.org@localhost>,
"port-hp300-maintainer%netbsd.org@localhost" <port-hp300-maintainer%netbsd.org@localhost>,
"gnats-admin%netbsd.org@localhost" <gnats-admin%netbsd.org@localhost>, "netbsd-bugs%netbsd.org@localhost"
<netbsd-bugs%netbsd.org@localhost>
Cc:
Subject: RE: port-hp300/50852: src/sys/arch/hp300/stand/common/ite.c:239:
bad expression
Date: Sat, 27 Feb 2016 07:52:56 +0000
Hello there=2C=0A=
=0A=
----------------------------------------=0A=
> However=2C I did see someone say that i =3D ++i + 1 is well-defined=0A=
> starting in *C++* 11.=0A=
=0A=
The code in question is C code. Let's leave what happens in C++ aside=2C=0A=
since it is only muddying the issue. =0A=
=0A=
Let's also leave aside what happens in various C language versions and conc=
entrate =0A=
on the language version the compiler uses for the netBSD code.=0A=
=0A=
=0A=
$ more feb27b.c=0A=
=0A=
#define NITE 4=0A=
=0A=
int=0A=
main()=0A=
{=0A=
=A0=A0=A0 int whichconsole =3D 0=3B=0A=
=A0=A0=A0 whichconsole =3D ++whichconsole % (NITE+1)=3B=0A=
=A0=A0=A0 return 0=3B=0A=
}=0A=
=0A=
First=2C with a recent version of clang=2C a well known C compiler.=0A=
=0A=
$ ~/llvm/results/bin/clang -c -g -O2 -Wall -Wextra feb27b.c=0A=
feb27b.c:8:17: warning: multiple unsequenced modifications to 'whichconsole=
'=0A=
=A0=A0=A0=A0=A0 [-Wunsequenced]=0A=
=A0=A0=A0=A0=A0=A0=A0 whichconsole =3D ++whichconsole % (NITE+1)=3B=0A=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 ~ ^=0A=
1 warning generated.=0A=
=0A=
Next a recent version of gcc.=0A=
=0A=
$ ~/gcc/results/bin/gcc -c -g -O2 -Wall -Wextra feb27b.c=0A=
feb27b.c: In function =91main=92:=0A=
feb27b.c:8:15: warning: operation on =91whichconsole=92 may be undefined [-=
Wsequence-point]=0A=
=A0 whichconsole =3D ++whichconsole % (NITE+1)=3B=0A=
=A0 ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~=0A=
$ =0A=
=0A=
Two different compilers=2C in their default language standard=2C think the =
code falls=0A=
foul of the C sequence point rules. =0A=
=0A=
I think it is *much* more likely that the original code is wrong than two s=
eparate compilers=0A=
have the same bug in them.=0A=
=0A=
=0A=
Regards=0A=
=0A=
David Binderman=0A=
=
Home |
Main Index |
Thread Index |
Old Index