https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90508
Bug ID: 90508 Summary: GCC does not produce full template backtraces when instantiating but not calling virtual functions Product: gcc Version: 8.3.0 Status: UNCONFIRMED 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 b> struct a { virtual b g() { return 0; } }; template <class T> void foo() { a<T>(); } void bar() { foo<void>(); } $ g++ -fsyntax-only x.cpp x.cpp: In instantiation of ‘b a<b>::g() [with b = void]’: x.cpp:2:15: required from here x.cpp:2:28: error: return-statement with a value, in function returning ‘void’ [-fpermissive] virtual b g() { return 0; } ^ $ cat y.cpp template <class b> struct a { virtual b g() { return 0; } }; template <class T> void foo() { a<T>().g(); } void bar() { foo<void>(); } $ g++ -fsyntax-only y.cpp y.cpp: In instantiation of ‘b a<b>::g() [with b = void]’: y.cpp:6:5: required from ‘void foo() [with T = void]’ y.cpp:9:15: required from here y.cpp:2:28: error: return-statement with a value, in function returning ‘void’ [-fpermissive] virtual b g() { return 0; } ^ $ g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/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 --enable-cet=auto Thread model: posix gcc version 8.3.0 (GCC) $ Both x.cpp and y.cpp fail to instantiate a<void>::g(), but y.cpp's failure gives the full template stack whereas x.cpp's failure just gives the location of g. This also happens in GCC 9 and trunk. However, in 7 and below it would point at the end of the function at the bottom of the template stack (e.g. x.cpp:10:1 instead of x.cpp:2:15).