https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85011
Bug ID: 85011 Summary: GCC complains that 2 identical function prototypes are different Product: gcc Version: 7.3.1 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: m101010a at gmail dot com Target Milestone: --- $ cat x.cpp template <class T> struct foo { int x; auto f1() -> decltype(x); }; template <class T> auto foo<T>::f1() -> decltype ((this)->foo<T>::x) {} $ g++ -v -fsyntax-only x.cpp Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --enable-multilib --disable-werror --enable-checking=release --enable-default-pie --enable-default-ssp Thread model: posix gcc version 7.3.1 20180312 (GCC) COLLECT_GCC_OPTIONS='-v' '-fsyntax-only' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/cc1plus -quiet -v -D_GNU_SOURCE x.cpp -quiet -dumpbase x.cpp -mtune=generic -march=x86-64 -auxbase x -version -fsyntax-only -o /dev/null GNU C++14 (GCC) version 7.3.1 20180312 (x86_64-pc-linux-gnu) compiled by GNU C version 7.3.1 20180312, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.18-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/../../../../x86_64-pc-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/../../../../include/c++/7.3.1 /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/../../../../include/c++/7.3.1/x86_64-pc-linux-gnu /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/../../../../include/c++/7.3.1/backward /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/include /usr/local/include /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/include-fixed /usr/include End of search list. GNU C++14 (GCC) version 7.3.1 20180312 (x86_64-pc-linux-gnu) compiled by GNU C version 7.3.1 20180312, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.18-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 7db9d5d3f13a1b145edda774ba2b8b66 x.cpp:5:25: error: prototype for ‘decltype (((foo<T>*)this)->foo<T>::x) foo<T>::f1()’ does not match any in class ‘foo<T>’ template <class T> auto foo<T>::f1() -> decltype ((this)->foo<T>::x) {} ^~~~~~ x.cpp:3:7: error: candidate is: decltype (((foo<T>*)this)->foo<T>::x) foo<T>::f1() auto f1() -> decltype(x); ^~ This error message is nonsensical, since it claims that the prototype for f1 on lines 3 and 5 differ, yet the error messages list the same prototype for each.