31 Dec
2003
31 Dec
'03
11:18
while (*s) { *s++ = toupper(*s); }
loop. What exactly makes the old heretic code so wrong in the eyes of ISO C? A list of example problematic code would be most welcome. (A proper warning from gcc when using optimization would be nice as well.)
The problem here are so called 'sequence points'. ';' is such a sequence point. Using s and s++ within the same sequence will result in undefined behaviour like you noticed. while (*s) { ... do stuff ... s++; } is fine. Ciao, Marcus