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

            Bug ID: 105511
           Summary: Spurious warning: "expected 'template' keyword..."
                    when lt and gt compare over ternary
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: cuzdav at gmail dot com
  Target Milestone: ---

Only on g++ 12 (new warning).

Building with the freshly released G++12 with warning enabled
(-Werror=missing-template-keyword)

Complete, minimized code:

template <typename X>
bool before(bool ascending, X & a, X * b) {
    return ascending ? a.value < (*b).value : a.value > (*b).value;
}


<source>:4:26: warning: expected 'template' keyword before dependent template
name [-Wmissing-template-keyword]
    4 |     return ascending ? a.value < (*b).value : a.value > (*b).value;
      |                          ^~~~~

Visible on Compiler Explorer
https://godbolt.org/z/dW9hjbdex

Yes, the left-angle and right-angle brackets are present, but it's not looking
quite hard enough to see that they are on opposite sides of a ternary ':'.


My Compiler, if it matters:
/opt/imc/gcc-12.1.0/bin/g++
(base) bash-4.2$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/opt/imc/gcc-12.1.0/libexec/gcc/x86_64-pc-linux-gnu/12.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-12.1.0/configure --prefix=/opt/imc/gcc-12.1.0
--enable-languages=c,c++,fortran,lto --disable-multilib
--with-build-time-tools=/home/trading/cuzdav/code/imc-gcc/gcc/12.1.0/INSTALLDIR//opt/imc/gcc-12.1.0/bin
--enable-libstdcxx-time=rt
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.1.0 (GCC)

Reply via email to