https://gcc.gnu.org/bugzilla/show_bug.cgi?id=32643
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |msebor at gcc dot gnu.org --- Comment #23 from Martin Sebor <msebor at gcc dot gnu.org> --- Bernd, intuitively, I would not expect a warning in the case you ask about. -Woverflow is documented to "warn about compile-time overflow in constant expressions." A strict reading of this single sentence would suggest that since none of the initialization expressions in the original test case is a constant expression no warning should be issued (and the initialization expressions should perhaps be diagnosed as not constant). Alternatively, the documentation for the warning should explain what GCC considers a constant expression (if more than what's required by the C standard) and in what contexts and under what circumstances (e.g., per Josephs's description in the post referenced in comment #10). Otherwise, what should or shouldn't be expected to be diagnosed is open to debate. FWIW, to illustrate, GCC rejects some expressions with an error and not others based on what it considers a constant expression (i.e., what it folds). In my view, that's more of a problem than the warning. $ cat t.c && gcc t.c unsigned char p; char p2 = p & 512; char p3 = p & 2; t.c:3:11: warning: overflow in implicit constant conversion [-Woverflow] char p2 = p & 512; ^ t.c:4:11: error: initializer element is not constant char p3 = p & 2; ^ With -Wpedantic there is also a redundant warning: t.c:3:11: warning: overflow in implicit constant conversion [-Woverflow] char p2 = p & 512; ^ t.c:3:1: warning: overflow in constant expression [-Woverflow] char p2 = p & 512; ^~~~ t.c:4:11: error: initializer element is not constant char p3 = p & 2; ^