Gabriel Dos Reis - Re: PATCH RFC: -Wstrict-overflow, take 2 (original) (raw)

This is the mail archive of the gcc-patches@gcc.gnu.orgmailing 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]

Ian Lance Taylor iant@google.com writes:

| Jonathan Lennox lennox@cs.columbia.edu writes: | | > Ian Lance Taylor wrote: | > | > > Here is a new version of my -Wstrict-overflow patch. This | > > incorporates all the comments made on the first version. | > | > > At -Wstrict-overflow=3 we get 31 warnings: | > | > > ../../trunk/gcc/expmed.c:3485: warning: assuming signed overflow does not | > > occur when changing X +- C1 cmp C2 to X cmp C1 +- C2 | > | > How hard would it be to change this diagnostic to print the actual values of | > "X", "+-", "C1", "cmp", and "C2"? | > | > For expmed.c:3485, for example, the warning would be | > | > ../../trunk/gcc/expmed.c:3485: warning: assuming signed overflow does not | > occur when changing "size - 1 < 32" to "size < 32 + 1" | > | > I think this would be much more accessible to people not versed in the | > intricacies of compilers, and also make it much easier (as in this case) to | > see at a glance if signed overflow could actually be a problem. | | Well, the X can, in general, be anything. As far as I know we don't | have a good way to dump general expressions in warning contexts.

We use the format specifier '%E' -- that prints out the C-level representation of the internal form. That may or may not be as pretty as the original source code depending on the complexity of the expression.

-- Gaby


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