From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6BB113858C53; Fri, 6 May 2022 23:50:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6BB113858C53 From: "cuzdav at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/105511] New: Spurious warning: "expected 'template' keyword..." when lt and gt compare over ternary Date: Fri, 06 May 2022 23:50:14 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 11.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: cuzdav at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 May 2022 23:50:14 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105511 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=3Dmissing-template-keyword) Complete, minimized code: template bool before(bool ascending, X & a, X * b) { return ascending ? a.value < (*b).value : a.value > (*b).value; } :4:26: warning: expected 'template' keyword before dependent templa= te 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 look= ing 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=3Dg++ COLLECT_LTO_WRAPPER=3D/opt/imc/gcc-12.1.0/libexec/gcc/x86_64-pc-linux-gnu/1= 2.1.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc-12.1.0/configure --prefix=3D/opt/imc/gcc-12.1.0 --enable-languages=3Dc,c++,fortran,lto --disable-multilib --with-build-time-tools=3D/home/trading/cuzdav/code/imc-gcc/gcc/12.1.0/INST= ALLDIR//opt/imc/gcc-12.1.0/bin --enable-libstdcxx-time=3Drt Thread model: posix Supported LTO compression algorithms: zlib gcc version 12.1.0 (GCC)=