Created attachment 22472 [details] reduced testcase Compiler output: $ gcc -O -fno-inline -fipa-cp -fipa-cp-clone -fcompare-debug testcase.C gcc: error: testcase.C: -fcompare-debug failure $ diff testcase.*gkd 46d45 < 0: const unsigned int D.xxxx; 47a47 > 0: const unsigned int D.xxxx; Tested revisions: r166976 - fail r165699 - fail r163636 - fail r161659 - OK 4.5 r166509 - OK
It is caused by revision 162156: http://gcc.gnu.org/ml/gcc-cvs/2010-07/msg00510.html
(In reply to comment #1) > It is caused by revision 162156: > > http://gcc.gnu.org/ml/gcc-cvs/2010-07/msg00510.html This patch gives a diagnosis for an internal compiler inconsistency. Having different orders of identifiers can lead to different compilation output, although if it actually does is down to a complex interaction of compiler internals that to all effects and purposes can be considered to be pseudo-random. See PR44832 for an example. The real question to be asked here is why the identifier order has changed.
Mine. The order changed because we discarded the typedef decl from the block scope in the original function. When the time came to clone it, we'd remap the typedef type after variable a3 of that type, and a3 would not be nonlocalized, whereas with debug info we retained the typedef, cloned the type first, and a3 would be nonlocalized. The patch I'm going to attach momentarily fixes this by keeping the typedef around.
Created attachment 22474 [details] Patch that fixes the problem This is the patch I'm testing.
Looks like a sledgehammer. Why does nonlocalize state depends on debug info?
It checks whether the var type was already remapped. tree-inline.c: can_be_nonlocal(...): /* We must use global type. We call remapped_type instead of remap_type since we don't want to remap this type here if it hasn't been remapped before. */ if (TREE_TYPE (decl) != remapped_type (TREE_TYPE (decl), id)) return false;
Yeah. FYI, I've tried to limit this to VLAs only in http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43942#c14 unfortunately it degraded debug info quality, so for now we really need all types.
Author: aoliva Date: Thu Jan 20 16:56:25 2011 New Revision: 169058 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=169058 Log: gcc/ChangeLog: PR debug/46583 * tree-ssa-live.c (remove_unused_scope_block_p): Keep type decls. gcc/testsuite/ChangeLog: PR debug/46583 * g++.dg/debug/pr46583.C: New. Added: trunk/gcc/testsuite/g++.dg/debug/pr46583.C Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-ssa-live.c
Fixed