Re: gcc not warning on all occurences of operations with undefined results?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Daniel Kabs napsal(a):

Hello there,

gcc 3.3.5 issues warnings on lines like

 a[i] = i++;
 i = i++;
 *p++ = func(*p);

e.g.
"test_increment.c:19: warning: operation on `i' may be undefined"

I take it, this is because of the C standard saying, that if I have an expression and somewhere in that expression, I use an increment (decrement) operator on a variable, I can not mention that variable elsewhere in the expression.

I think, that this is wrong. The exact rule should be more like "...if the result of the operation is not defined by standard..."

The warnings are very helpful in finding badly written expressions.

But why doesn't gcc warn about this code

 s.a = s.a++;
 p->a = p->a++;
because in both these cases the result *is* defined

IMHO, these lines also infringe upon the above mentioned rule or did I miss something important?
Cheers
Daniel
-L


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux