[Bug c++/78217] New: Duplicate decls handling with auto

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat Nov 5 06:48:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78217

            Bug ID: 78217
           Summary: Duplicate decls handling with auto
           Product: gcc
           Version: 6.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jakub at gcc dot gnu.org
  Target Milestone: ---

I've noticed that we error out in both cases on following testcase:
extern int a;
auto a = 1;
extern int b;
auto b = 2LL;
test.C:2:6: error: conflicting declaration ‘auto a’
 auto a = 1;
      ^
test.C:1:12: note: previous declaration as ‘int a’
 extern int a;
            ^
test.C:4:6: error: conflicting declaration ‘auto b’
 auto b = 2LL;
      ^
test.C:3:12: note: previous declaration as ‘int b’
 extern int b;
            ^
while clang++ rejects only the latter:
test.C:4:6: error: redefinition of 'b' with a different type: 'long long' vs
'int'
auto b = 2LL;
     ^
test.C:3:12: note: previous declaration is here
extern int b;
           ^
1 error generated.

That is because we perform duplicate_decls already at start_decl time, but we
probably need to defer it for the auto deduction cases until cp_finish_decl
time when we actually know the type.


More information about the Gcc-bugs mailing list