From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1B8E53858009; Mon, 31 Oct 2022 20:43:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1B8E53858009 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667249000; bh=SN3NPhBIZA4wVRsTKENmowHXapn4M26PIUK5qtfDDKw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=D+4hcL7nra/fSBirpWXa67Po12uLGWTyzD73HhnDWJzm5KhB2q2NPEaU/RejCbDxA NR2rY5G3c+qSug/EM0vT5XOi/LHekA7lE7UcLaIO76U3lUetRoeTggjE2SZx7HWeg+ l0E76Bgn5pHoFkn9+YlER65ffAA1PTQ0GBjm5NOQ= From: "mpolacek at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/105511] [12/13 Regression] Spurious warning: "expected 'template' keyword..." when lt and gt compare over ternary Date: Mon, 31 Oct 2022 20:43:19 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.1.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: mpolacek at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105511 Marek Polacek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mpolacek at gcc dot gnu.org --- Comment #2 from Marek Polacek --- I'm not sure if there's anything to fix; the manual says: In rare cases it is possible to get false positives. To silence this, wrap the expression in parentheses. For example, the following is treated as a template, even where m and N are integers: @smallexample void NotATemplate (my_class t) @{ int N =3D 5; bool test =3D t.m < N > (0); // Treated as a template. test =3D (t.m < N) > (0); // Same meaning, but not treated as a template. @} @end smallexample so return ascending ? (a.value < (*b).value) : a.value > (*b).value; prevents the warning.=