On Tue, Jan 28, 2014 at 8:11 AM, Thomas Schwinge <tho...@codesourcery.com> wrote: > On Tue, 28 Jan 2014 06:52:30 -0800, Ian Lance Taylor <i...@google.com> wrote: >> On Tue, Jan 28, 2014 at 6:36 AM, Thomas Schwinge >> <tho...@codesourcery.com> wrote: >> > Avoid "'dc' may be uninitialized" warning. >> > >> > libiberty/ >> > * cp-demangle.c (d_demangle_callback): Put __builtin_unreachable >> > in place, to help the compiler. > > For my own education: why is this not considered a GCC trunk bug? It is > xgcc/cc1 which is coming up with this (bogus?) warning, but only for -Og > and not for -O0, -O1, etc.?
I don't really have an opinion on whether this is a bug in GCC or not. Since libiberty is compiled by other compilers, I think your cp-demangle.c patch is reasonable and appropriate either way. In particular, it's not a bug for the compiler to consider the possibility that type may take on a value not named in the enum. C/C++ impose no restrictions on values of enum type. It's valid to write code that stores a value that is not an enum constant into a variable of enum type, so it's reasonable for the compiler to consider the possibility, even though we can clearly see that it can not happen. I don't know why the compiler reports a different warning for -O1 and -Og. I encourage you to reduce the code into a standalone test case and file a bug report. Ian