http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51640
Bug #: 51640 Summary: Misleading error if the type in the catch() is ambiguous Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: minor Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: pets...@gmail.com Created attachment 26154 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26154 test case that triggers the bug There is a regression from g++ 4.4 in later versions. If the name of the class is ambiguous in a catch(), this fact is not reported. At line 25 when compiling the attached test case with 4.5.x, 4.6.x or 4.7.0, the ambiguity of the type name 'ex2' is not mentioned. 4.4.6 reports the ambiguity at the catch(), though for other ambiguities (at variable definition, class declaration w/ ambiguous parent) it prints the message twice. 4.5 and above versions print the error once in these latter cases. I suspect that this regression might be connected to fixing the duplicated error printing. Tested on an amd64 machine with Debian Wheezy, stock 4.4, 4.5, 4.6 versions (4.4.6-14, 4.5.3-9, 4.6.2-7) and 4.7.0 built from svn trunk r182460. The original cpp file is attached, since it doesn't have any preprocessor directives except for comments. Command line and output: g++-r182460 -v -save-temps -Wall -Wextra -c test_gccexbug2.cpp Using built-in specs. COLLECT_GCC=g++-r182460 COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ./configure --program-suffix -r182460 Thread model: posix gcc version 4.7.0 20111219 (experimental) (GCC) COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-Wextra' '-c' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/cc1plus -E -quiet -v -D_GNU_SOURCE test_gccexbug2.cpp -mtune=generic -march=x86-64 -Wall -Wextra -fpch-preprocess -o test_gccexbug2.ii ignoring nonexistent directory "/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../x86_64-unknown-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0 /usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/x86_64-unknown-linux-gnu /usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/backward /usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/include /usr/local/include /usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/include-fixed /usr/include End of search list. COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-Wextra' '-c' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/cc1plus -fpreprocessed test_gccexbug2.ii -quiet -dumpbase test_gccexbug2.cpp -mtune=generic -march=x86-64 -auxbase test_gccexbug2 -Wall -Wextra -version -o test_gccexbug2.s GNU C++ (GCC) version 4.7.0 20111219 (experimental) (x86_64-unknown-linux-gnu) compiled by GNU C version 4.7.0 20111218 (experimental), GMP version 5.0.2, MPFR version 3.1.0-p3, MPC version 0.9 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 GNU C++ (GCC) version 4.7.0 20111219 (experimental) (x86_64-unknown-linux-gnu) compiled by GNU C version 4.7.0 20111218 (experimental), GMP version 5.0.2, MPFR version 3.1.0-p3, MPC version 0.9 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 Compiler executable checksum: fafea236350b995726228b0b21cd1771 test_gccexbug2.cpp: In function ‘void bar()’: test_gccexbug2.cpp:25:11: error: expected type-specifier before ‘ex2’ test_gccexbug2.cpp:25:14: error: expected ‘)’ before ‘&’ token test_gccexbug2.cpp:25:14: error: expected ‘{’ before ‘&’ token test_gccexbug2.cpp:25:15: error: expected primary-expression before ‘)’ token test_gccexbug2.cpp:25:15: error: expected ‘;’ before ‘)’ token