public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/105511] New: Spurious warning: "expected 'template' keyword..." when lt and gt compare over ternary @ 2022-05-06 23:50 cuzdav at gmail dot com 2022-10-31 1:45 ` [Bug c++/105511] [12/13 Regression] " pinskia at gcc dot gnu.org ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: cuzdav at gmail dot com @ 2022-05-06 23:50 UTC (permalink / raw) To: gcc-bugs 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) ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/105511] [12/13 Regression] Spurious warning: "expected 'template' keyword..." when lt and gt compare over ternary 2022-05-06 23:50 [Bug c++/105511] New: Spurious warning: "expected 'template' keyword..." when lt and gt compare over ternary cuzdav at gmail dot com @ 2022-10-31 1:45 ` pinskia at gcc dot gnu.org 2022-10-31 20:43 ` mpolacek at gcc dot gnu.org 2022-12-20 13:42 ` rguenth at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: pinskia at gcc dot gnu.org @ 2022-10-31 1:45 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105511 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Known to work| |11.1.0, 11.3.0 Summary|Spurious warning: "expected |[12/13 Regression] Spurious |'template' keyword..." when |warning: "expected |lt and gt compare over |'template' keyword..." when |ternary |lt and gt compare over | |ternary Known to fail| |12.1.0 Target Milestone|--- |12.3 Ever confirmed|0 |1 Last reconfirmed| |2022-10-31 --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Confirmed. r12-6563-gb8ffa71e4271ae introduced the warning and enabled it by default. I say this is a regression since the warning is enabled by default and I can't even see how to avoid the warning. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/105511] [12/13 Regression] Spurious warning: "expected 'template' keyword..." when lt and gt compare over ternary 2022-05-06 23:50 [Bug c++/105511] New: Spurious warning: "expected 'template' keyword..." when lt and gt compare over ternary cuzdav at gmail dot com 2022-10-31 1:45 ` [Bug c++/105511] [12/13 Regression] " pinskia at gcc dot gnu.org @ 2022-10-31 20:43 ` mpolacek at gcc dot gnu.org 2022-12-20 13:42 ` rguenth at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: mpolacek at gcc dot gnu.org @ 2022-10-31 20:43 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105511 Marek Polacek <mpolacek at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mpolacek at gcc dot gnu.org --- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> --- 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 = 5; bool test = t.m < N > (0); // Treated as a template. test = (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. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/105511] [12/13 Regression] Spurious warning: "expected 'template' keyword..." when lt and gt compare over ternary 2022-05-06 23:50 [Bug c++/105511] New: Spurious warning: "expected 'template' keyword..." when lt and gt compare over ternary cuzdav at gmail dot com 2022-10-31 1:45 ` [Bug c++/105511] [12/13 Regression] " pinskia at gcc dot gnu.org 2022-10-31 20:43 ` mpolacek at gcc dot gnu.org @ 2022-12-20 13:42 ` rguenth at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: rguenth at gcc dot gnu.org @ 2022-12-20 13:42 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105511 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |WONTFIX --- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> --- So indeed it works as documented, thus WONTFIX. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-12-20 13:42 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-05-06 23:50 [Bug c++/105511] New: Spurious warning: "expected 'template' keyword..." when lt and gt compare over ternary cuzdav at gmail dot com 2022-10-31 1:45 ` [Bug c++/105511] [12/13 Regression] " pinskia at gcc dot gnu.org 2022-10-31 20:43 ` mpolacek at gcc dot gnu.org 2022-12-20 13:42 ` rguenth at gcc dot gnu.org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).