Consider the following code: template <typename T> //no warning if this is not a template struct X { T v; }; template <typename T> inline void f() { X<T> x; //no warning with e.g. X<int> if(x.v < 0 && 0 > -1) {} //No warning without the "-" } int main() { f<int>(); //Still get a warning without this instantiation. } GCC 12, 13, current trunk and seemingly everything after b8ffa71e427 give me a warning for this: warning: expected 'template' keyword before dependent template name [-Wmissing-template-keyword] But GCC compiles it, so it seems to interpret it correctly at some point after triggering the warning. I tried to look into it and thought that maybe cp_lexer_peek_token (parser->lexer)->type <= CPP_LAST_PUNCTUATOR in line 6447 of gcc/cp/parser.cc is too general but I do not have a proposed patch.
A command line that can trigger the behavior is g++ main.cpp One of the versions for which it occurs is g++ -v Es werden eingebaute Spezifikationen verwendet. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/lto-wrapper Ziel: x86_64-pc-linux-gnu Konfiguriert mit: /build/gcc/src/gcc/configure --enable-languages=ada,c,c++,d,fortran,go,lto,objc,obj-c++ --enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --with-build-config=bootstrap-lto --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-libstdcxx-backtrace --enable-link-serialization=1 --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-werror Thread-Modell: posix Unterstützte LTO-Kompressionsalgorithmen: zlib zstd gcc-Version 13.2.1 20230801 (GCC)
Confirmed.
Started with r12-6563-gb8ffa71e4271ae: commit b8ffa71e4271ae562c2d315b9b24c4979bbf8227 Author: Anthony Sharp <anthonysharp15@gmail.com> Date: Sat Dec 4 17:23:22 2021 +0000 c++: warning for dependent template members [PR70417] But is seems to me this is the case of a false positive <https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wmissing-template-keyword> talks about. Wrapping "x.v < 0" in () suppresses the warning.
GCC 12.4 is being released, retargeting bugs to GCC 12.5.