tertiary operator bug?
Martin v. Loewis
martin@loewis.home.cs.tu-berlin.de
Sat May 27 15:22:00 GMT 2000
> Here's the source to demonstrate a funky bug with egcs-2.91.66. I
> realize that using the statement x=(x<<=1) is dumb to begin with,
> but it shouldn't break the compiler. The mal-effect is that the
> array (which is supposed to be read only) is overwritten.
Thanks for your bug report. This is not a bug in the compiler, but a
bug in your code. In ISO C,
a ? b : c <<= d;
is ill-formed. GCC treats it as an extension, and considers it as
(a ? b:c) <<= d
if both b and c are lvalues, see the section "Lvalues" of the gcc
manual. In your case, it means the <<=1 applies to both v.v.q, and
qSFST1T[v.v.q]. If you compile the code with -pedantic, it says
a.c:31: warning: ANSI C forbids use of conditional expressions as lvalues
Regards,
Martin
More information about the Gcc-bugs
mailing list