This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: warning: operation on 'zero' may be undefined


Paul Brook wrote:

>> foo.cxx: In function `int main()':
>> foo.cxx:4: warning: operation on 'zero' may be undefined
>> 
>> What does this mean ?
> 
> You incrementing and assigning to the same variable in one statement,
> which invokes undefined behaviour.
> 
> The code you wrote can be interpreted as
> zero = zero%3;
> or
> zero = (zero % 3) + 1
> or possibly even something entirely different.

The error message could use a clarification though.

Giovanni Bajo



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]