[nycbug-talk] MSNBC on the decline of technology jobs

Marc Spitzer mspitzer
Wed Jun 22 20:51:43 EDT 2005


On 6/22/05, Bob Ippolito <bob at redivi.com> wrote:
> 
> On Jun 22, 2005, at 3:00 PM, Marc Spitzer wrote:
> > here I would vote for 2, gcc says 1
> > 1: c=0
> > 2: ++c ( c= 0+1)
> > 3 c= c+c (c = 1+1)
> 
> GCC says 1 because you don't remember C syntax correctly.  =+ isn't
> in-place addition, it is plain old assignment with a unary plus
> operator (effectively a no-op).  If you had done += then it would've
> been 2.

Thanks for the pointer, it has been years.  And I always tried not to
be cute, always cost me more time debugging then it saved in not
writing 2 or 3 lines instead of 1.

> 
> What GCC is doing here is this:
> 
> 1. c=0
> 2. ++c (c = 0 + 1)
> 3. c = c (c = 1)
> 
> >> someone thinks about resolving this: Break the statement into
> >> operations,
> >> and try to figure whether assignment or post-increment will happen
> >> first.
> >>
> >
> > by definition post incrament happens after assignment, again compilers
> > may vary but that is how it should work
> 
> Yeah, if the answer is not 1, then the compiler has a bug.
> 
> -bob
> 
>




More information about the talk mailing list