http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59323
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2013-11-28 Target Milestone|--- |4.9.0 Ever confirmed|0 |1 --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- Confirmed. Nested functions. There seems to be a declaration coming in from BLOCK_VARS #5 0x000000000074b91a in decls_for_scope (stmt=<block 0x7ffff6e4f190>, context_die=0x7ffff6e4f050, depth=2) at /space/rguenther/src/svn/trunk/gcc/dwarf2out.c:19971 but the decl itself has non-BLOCK scope (its DECL_CONTEXT is the main fn). There are two BLOCKs which contain the exact same BLOCK_VARs ... So it seems we duplicate BLOCKs either bogously during streaming (maybe only in the context of nested functions) or they are duplicate also in the compile phase. It seems that one BLOCK is BLOCK_SUPERCONTEXT of the other which cannot really be a streaming artifact. It's a tree merging artifact - we merge the TYPE_DECLs for enum { X }; which end up being written to the global section despite their DECL_CONTEXT being a FUNCTION_DECL (bah). Such merging happens without considering DECL_CHAIN as we assume they are not in BLOCK context. They end up there because the nested function decl 'foo' is in that same block (I think) and thus they form a tree SCC via BLOCK_VARS. Ah no - it's ultimately the CONST_DECL for X that pulls the enum type and its type decl global. Ick... I have a fix.