https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79204
Bug ID: 79204 Summary: improve -Woverflow by mentioning types and values Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- In a non-trivial program where types are "hidden" behind typedefs and constant expressions by layers of macros and/or enums, diagnostics such as overflow could be improved by mentioning the types of the operands and their (constant) values. For example, in the program below the typedefs and macros can be defined in headers and far removed from initialization of x, and neither the warning nor the note may give a clue as to what they expand to. $ cat t.c && gcc -S -Wall t.c typedef signed char T; #define X 123 #define Y 234 #define N (X * Y) T x = N; t.c:4:11: warning: overflow in implicit constant conversion [-Woverflow] #define N (X * Y) ^ t.c:6:7: note: in expansion of macro āNā T x = N; ^ As an example of a possible improvement consider the Clang output for the same test case: t.c:6:7: warning: implicit conversion from 'int' to 'T' (aka 'signed char') changes value from 28782 to 110 [-Wconstant-conversion] T x = N; ~ ^ t.c:4:14: note: expanded from macro 'N' #define N (X * Y) ~~^~~