[Bug c++/64679] New: Spurious redefinition error when parsing not-quite-most-vexing-parse declarations

rs2740 at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue Jan 20 01:30:00 GMT 2015


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

            Bug ID: 64679
           Summary: Spurious redefinition error when parsing
                    not-quite-most-vexing-parse declarations
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rs2740 at gmail dot com

Repro:

class Bar{
public:
  Bar(int, int, int);
};

int main () {
  int x = 1;
  Bar bar(int(x), int(x), int{x});
}

gcc HEAD 5.0.0 20150119 (experimental) with g++ prog.cc -Wall -Wextra
-std=gnu++1y reports:

prog.cc: In function 'int main()':
prog.cc:8:24: error: redefinition of 'int x'
  Bar bar(int(x), int(x), int{x});
                       ^
prog.cc:8:16: note: 'int x' previously declared here
  Bar bar(int(x), int(x), int{x});

With the last int{x} (note the braces) this cannot be a function declaration,
but g++ appears to emit the redefinition errors too early, before the full
declaration is parsed. Clang compiles this successfully.



More information about the Gcc-bugs mailing list