public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/66924] New: Bad diagnostic for parameter name used as non-type template argument
@ 2015-07-18  2:00 david.godfrey99 at gmail dot com
  2024-04-15 23:25 ` [Bug c++/66924] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: david.godfrey99 at gmail dot com @ 2015-07-18  2:00 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 66924
           Summary: Bad diagnostic for parameter name used as non-type
                    template argument
           Product: gcc
           Version: 5.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: david.godfrey99 at gmail dot com
  Target Milestone: ---

GCC does not give a good diagnostic for the following code:

template<int>
constexpr int variable{};

int main() {
    auto f = [] (int x) -> decltype(variable<x>) {return{};};
}

The error is

error: parse error in template argument list
     auto f = [] (int x) -> decltype(variable<x>) {return{};};
                                     ^
main.cpp:5:37: error: template argument 1 is invalid

This code is ill-formed, but the error should explain how x is not a constant
expression (as parameter names are never constant expressions).


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/66924] Bad diagnostic for parameter name used as non-type template argument
  2015-07-18  2:00 [Bug c++/66924] New: Bad diagnostic for parameter name used as non-type template argument david.godfrey99 at gmail dot com
@ 2024-04-15 23:25 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-15 23:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note the "parse error" part of the diagnostic is no longer there on the trunk
(for GCC 14).

clang produces:
```
<source>:6:46: error: non-type template argument is not a constant expression
    6 |     auto f = [] (int x) -> decltype(variable<x>) {return{};};
      |                                              ^
<source>:6:46: note: function parameter 'x' with unknown value cannot be used
in a constant expression
<source>:6:22: note: declared here
    6 |     auto f = [] (int x) -> decltype(variable<x>) {return{};};
      |                      ^
```

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-04-15 23:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-18  2:00 [Bug c++/66924] New: Bad diagnostic for parameter name used as non-type template argument david.godfrey99 at gmail dot com
2024-04-15 23:25 ` [Bug c++/66924] " pinskia 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).