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

            Bug ID: 63377
           Summary: Bad diagnostic - "expected unqualified-id" instead of
                    "no type named __ in namespace"
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: b_filip at zoho dot com

Here is a simple code that reproduces the problem, clang reports the error much
better:

temp@host $ cat gcc_clang_example.cpp 
#include <iostream>

int main() {
    try {}
    catch (const std::invalid_argument&) {}
}
temp@host $ g++ gcc_clang_example.cpp 
gcc_clang_example.cpp: In function ‘int main()’:
gcc_clang_example.cpp:5:39: error: expected unqualified-id before ‘&’ token
     catch (const std::invalid_argument&) {}
                                       ^
gcc_clang_example.cpp:5:39: error: expected ‘)’ before ‘&’ token
gcc_clang_example.cpp:5:39: error: expected ‘{’ before ‘&’ token
gcc_clang_example.cpp:5:40: error: expected primary-expression before ‘)’ token
     catch (const std::invalid_argument&) {}
                                        ^
gcc_clang_example.cpp:5:40: error: expected ‘;’ before ‘)’ token
temp@host $ clang++ gcc_clang_example.cpp 
gcc_clang_example.cpp:5:23: error: no type named 'invalid_argument' in
namespace 'std'
    catch (const std::invalid_argument&) {}
                 ~~~~~^
1 error generated.
temp@host $ 




Version of gcc:
Using built-in specs.
COLLECT_GCC=/usr/x86_64-pc-linux-gnu/gcc-bin/4.8.3/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.8.3/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-4.8.3/work/gcc-4.8.3/configure
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr
--bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.8.3
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.3
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.3/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.3/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/include/g++-v4
--with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.8.3/python
--enable-languages=c,c++,fortran --enable-obsolete --enable-secureplt
--disable-werror --with-system-zlib --enable-nls --without-included-gettext
--enable-checking=release --with-bugurl=https://bugs.gentoo.org/
--with-pkgversion='Gentoo 4.8.3 p1.1, pie-0.5.9' --enable-libstdcxx-time
--enable-shared --enable-threads=posix --enable-__cxa_atexit
--enable-clocale=gnu --enable-multilib --with-multilib-list=m32,m64
--disable-altivec --disable-fixed-point --enable-targets=all --disable-libgcj
--enable-libgomp --disable-libmudflap --disable-libssp --enable-lto
--without-cloog
Thread model: posix
gcc version 4.8.3 (Gentoo 4.8.3 p1.1, pie-0.5.9)

OS is Gentoo

Reply via email to