This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: output difference between VC and gcc
- From: Segher Boessenkool <segher at kernel dot crashing dot org>
- To: Peter <one2001boy at yahoo dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Sat, 17 Jul 2010 18:24:44 +0200
- Subject: Re: output difference between VC and gcc
- References: <624538.15375.qm@web55801.mail.re3.yahoo.com>
printf("%d:%d\n",i,tab[i++]);
based on C standard, whose output is correct?
The program exhibits undefined behaviour: it reads "i" twice while also
writing it, without any intervening sequence point. See e.g. 6.5/2 in
the C99 standard.
Segher