Article View: comp.sys.ibm.pc.programmer
Article #111Re: post increment (was Best C Compiler)
From: Lloyd Parkes
Date: Wed, 21 Mar 1990 23:28
Date: Wed, 21 Mar 1990 23:28
21 lines
1438 bytes
1438 bytes
Your code was:
> main()
> {
> int a=0;
> int *b= &a;
> printf("%d\n", (*b) + (a++) );
> }
I was always under the impression that while C defined operator
precedence, and operator associativity, it didn't define order of
evaluation for arithmetic. Hence GCC is simply evaluating the left
hand side first, which is completely legal. I don't write code like
that because I never know how it will turn out.
Lloyd
Disclaimer: Well, I could be wrong.
--
------------------------------------------------------------------------
Lloyd | lloyd@comp.vuw.ac.nz | "... I can gleek upon occasion." -
Parkes | ...!uunet!vuwcomp!lloyd | Nick Bottom
------------------------------------------------------------------------
Technical Details
Message-ID:
<LLOYD.90Mar22092857@circa.comp.vuw.ac.nz>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!samsung!zaphod.mps.ohio-state.edu!usc!apple!ames!uhccux!munnari.oz.au!kaukau.comp.vuw.ac.nz!lloydReferences:
<1722@geocub.greco-prog.fr> <1264@doitcr.doit.sub.org> <1990Mar19.175316.16898@Octopus.COM> <9873@wpi.wpi.edu> <9954@wpi.wpi.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!samsung!zaphod.mps.ohio-state.edu!usc!apple!ames!uhccux!munnari.oz.au!kaukau.comp.vuw.ac.nz!lloyd From: L.Parkes@comp.vuw.ac.nz (Lloyd Parkes) Newsgroups: comp.sys.ibm.pc.programmer Subject: Re: post increment (was Best C Compiler) Message-ID: <LLOYD.90Mar22092857@circa.comp.vuw.ac.nz> Date: 21 Mar 90 23:28:57 GMT References: <1722@geocub.greco-prog.fr> <1264@doitcr.doit.sub.org> <1990Mar19.175316.16898@Octopus.COM> <9873@wpi.wpi.edu> <9954@wpi.wpi.edu> Sender: news@kaukau.comp.vuw.ac.nz (News Admin) Organization: Victoria University of Wellington, Wellington, New Zealand Lines: 21 In-Reply-To: jhallen@wpi.wpi.edu's message of 21 Mar 90 06:21:09 GMT