public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/106631] New: Unhelpful diagnostic on variable template specialization with unknown name
@ 2022-08-15 21:24 barry.revzin at gmail dot com
  2022-08-16 15:49 ` [Bug c++/106631] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: barry.revzin at gmail dot com @ 2022-08-15 21:24 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 106631
           Summary: Unhelpful diagnostic on variable template
                    specialization with unknown name
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: barry.revzin at gmail dot com
  Target Milestone: ---

Short example:

template <class T>
constexpr bool trait = true;

template <>
constexpr bool triat<int> = false;

Note the typo on triat.

The current error message gcc provides is:

<source>:5:21: error: expected initializer before '<' token
    5 | constexpr bool triat<int> = false;
      |                     ^

Which is... technically true. Given that triat doesn't exist as a variable
template, the next thing coming up needs to be an initializer for it, since
this is really a declaration. But the intent was for it to specialize trait -
it seems like it's more likely that this kind of error would come from getting
the name of the variable template wrong rather than spelling the initializer
incorrectly?

So something like:

<source>:5:21: error: unknown variable template 'triat' being specialized
    5 | constexpr bool triat<int> = false;
      |                ^~~~~
    note: did you mean trait?

Would be much more helpful.

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

* [Bug c++/106631] Unhelpful diagnostic on variable template specialization with unknown name
  2022-08-15 21:24 [Bug c++/106631] New: Unhelpful diagnostic on variable template specialization with unknown name barry.revzin at gmail dot com
@ 2022-08-16 15:49 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-08-16 15:49 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement

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

end of thread, other threads:[~2022-08-16 15:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-15 21:24 [Bug c++/106631] New: Unhelpful diagnostic on variable template specialization with unknown name barry.revzin at gmail dot com
2022-08-16 15:49 ` [Bug c++/106631] " 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).