This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: tertiary operator bug?
- To: davek at ca dot mgisoft dot com
- Subject: Re: tertiary operator bug?
- From: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Date: Sun, 28 May 2000 00:20:32 +0200
- CC: gcc-bugs at gcc dot gnu dot org
- References: <392F0CA5.CC5E1233@ca.mgisoft.com>
> 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