This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: tertiary operator bug?


> 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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]