This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Is this a bug?
- From: Andrew Haley <aph at redhat dot com>
- To: Honggang Xu <hxu at zeugmasystems dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Thu, 16 Jul 2009 19:17:25 +0100
- Subject: Re: Is this a bug?
- References: <DDFD17CC94A9BD49A82147DDF7D545C50176D5AE@exchange.ZeugmaSystems.local> <DDFD17CC94A9BD49A82147DDF7D545C501CFB20D@exchange.ZeugmaSystems.local>
Honggang Xu wrote:
> Or my understand of keyword "volatile" is wrong, following code outputs
> compiled by gcc 4.1.1: x=22 ,y=59
>
> main()
> {
> volatile int x=20,y=35;
> x=y++ + x++;
> y= ++y + ++x;
> printf("x=%d y=%d\n" ,x,y);
>
> }
No, it's not a gcc bug: your program exhibits undefined behaviour.
http://c-faq.com/expr/ieqiplusplus.html
Andrew.