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: wierd results


george josilo wrote:

> I seem to get wierd results when i do:
>
> main()
> {
> int a=0;
> printf("%d %d %d %d\n", a, ++a, ++a, a);
> }
>
> most other compilers (MS), SparcWorks,
> give: 2 2 1 0 (evaluation in reverse order)
>
> gcc(v2.7.2, v2.8.1)
>
> give 2 1 2 2
>
> am I missing something?

Yep. Your program is mailformed - you can change a variable in an
expression only once and you are trying to do that two times.

> ŠorŠe Josilo - mailto:josilo@lucent.com                 | ZAP   ''''

Dima


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