At 11:04 PM 12/2/2010, Ethan Dicks wrote:
On Thu, Dec 2, 2010 at 7:48 PM, Fred Cisin <cisin at
xenosoft.com> wrote:
On Thu, 2 Dec 2010, Eric Smith wrote:
A[i++] =
i++;
I can't quote chapter and verse, but I'm fairly sure the standard
will
say that the result of that assignment is undefined.
C can be pretty loose about letting you do such.
There are many things that folks commonly do that are officially
undefined... like strlen(NULL) (that returned 0 on an NCR box but
segfaulted a SPARC - the NCR guys tried to claim it proved the Sun was
broken, but I had to point out that it's undefined).
I remember this with a large potential customer with a bunch of
applications running on HP-UX that needed to be ported to ULTRIX.
lots of code like
strcpy(foo, NULL);
used to initialize strings and
strcmp(foo, NULL)
to see if a string is empty, etc. Apparently location 0 in memory had a
zero.
Fixing this required a lot of work, then we had to fix binary blobs
written to disk (big-endian) to fix them to little-endian.
All of this was used to demonstrate that the DEC platform was obviously
unusable.
Aren't sales reps fun?
Probably more relevant to the compiler optimization thread, another fun
with marketing incident was the Sun rep handing our customer a "simple
little benchmark" that their compiler apparently recognized and
optimized out. The SPARC ran it in seconds while our MIPS based machine
took quite a while. This was my first run-in with the benchmark
preprocessor that did "deep optimization" of the SPECmark benchmarks.
-Rick