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: Weird result for modulus operation


Thanks for the speedy reply. But why this code:

        int a = 17, b = 16;
        a = a++ % 16;

Huh? Now you got me confused. Since it is an undefined behaviour, gcc is free to whatever it likes.

Sure, but if you ask gcc to signal a warning, it is supposed to do so. :-) It is a bug that gcc with -Wsequence-point signals a warning for "a = a++ % 16" but not when you use abc.a.


Though the answer given by the first and second examples show inconsistency in gcc in handling the undefined behaviour.

That's not a problem. GCC does not have to be consistent. But both should be warned about.


I can't forward to gmane.comp.gcc.devel newsgroup with my account.

No problem, you can delete it.


Paolo


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