While mucking around with gcc internals, I noticed that occasionally the
same tree can occur several times in the same cfun->local_decls list.
That seems like a bug(let).  Here's a testcase:

  int f() {}
  void g(void) { f(); }

The problem shows up at -O2, presumably due to inlining:
  gcc -c -O2 testcase.c
To make the problem easy to see, I'll attach a debugging patch to this PR
that causes "error: Repeated variable in list of local declarations" to be
printed if a repeated variable is detected.  You have to set
VERIFY_LOCAL_DECLS in the environment for the patch to do anything.
Here's an example session:

$ export VERIFY_LOCAL_DECLS=true
$ gcc -c -O2 testcase.c
testcase.c: In function ‘__float128’:
testcase.c:2:1: error: Repeated variable in list of local declarations

I have no idea why it thinks the function is called __float128.


-- 
           Summary: Variables can occur multiple times in cfun->local_decls
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: baldrick at free dot fr
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41339

Reply via email to