https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90410
Bug ID: 90410 Summary: [feature request] -fdiagnostics-show-template-tree should expand mismatched reference parameters Product: gcc Version: 8.2.1 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,class> struct s{}; void byval(s<long,long>); void byref(s<long,long>&); void bycref(const s<long,long>&); void g(s<int,long> v) { byval(v); byref(v); bycref(v); } $ g++ -fsyntax-only -fdiagnostics-show-template-tree x.cpp x.cpp: In function 'void g(s<int, long int>)': x.cpp:7:11: error: could not convert 'v' from 's<int,[...]>' to 's<long int,[...]>' s< [int != long int], [...]> byval(v); ^ x.cpp:8:11: error: invalid initialization of reference of type 's<long int, long int>&' from expression of type 's<int, long int>' byref(v); ^ x.cpp:3:6: note: in passing argument 1 of 'void byref(s<long int, long int>&)' void byref(s<long,long>&); ^~~~~ x.cpp:9:12: error: invalid initialization of reference of type 'const s<long int, long int>&' from expression of type 's<int, long int>' bycref(v); ^ x.cpp:4:6: note: in passing argument 1 of 'void bycref(const s<long int, long int>&)' void bycref(const s<long,long>&); ^~~~~~ $ g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.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 --enable-cet=auto Thread model: posix gcc version 8.2.1 20181127 (GCC) When taking s by value, -fdiagnostics-show-template-tree expands the template tree and shows exactly which parts differ between the declaration and the caller. When taking s by reference the tree is not expanded, and the similar parts are not elided. This behavior started in GCC 8.1 and persists in 9.1 and trunk.