This is the mail archive of the gcc@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: Tree generation bug or a feature?


On Wed, 24 May 2000 16:48:47 +0400, you wrote:

>Hi!
>
>
>With the following two statements, I supposed to get identical result:
>
>x = 2;  y = ++x * ++x;
>x = 2;  y = (x+=1) * (x+=1);
>
>However, under gcc  ++x  variant  gives me 16 instead if 12,
>as well as x++ * x++ incorrectly (I suppose) gives 4.
>
>
>Digital C compiler from DU 4.0 show correct values:
>
>++x * ++x = 12
>(x+=1) * (x+=1) = 12
>
>as well as gdb builtin C expression parser.
>
>
>Sounds like a tree generation bug, isn't it?

In these code snippets, you are trying to modify x's value more than
once, which makes these snippets undefined as per section 6.3 of the
ANSI/ISO C Standard. That is you cannot expect any particular result at
all.

>Yuri Pudgorodsky

Dima

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