public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/106354] New: Diagnostic could be more user friendly
@ 2022-07-19 13:50 barry.revzin at gmail dot com
  2022-07-19 13:58 ` [Bug c++/106354] " redi at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: barry.revzin at gmail dot com @ 2022-07-19 13:50 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 106354
           Summary: Diagnostic could be more user friendly
           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: ---

Consider:

template <typename T>
constexpr bool some_check() {
    return true;
}

struct C { };

static_assert(some_check<C>::value);

This is (obviously) wrong: some_check is a function template, not a type trait,
so the correct way to validate it is some_check<C>() and not
some_check<C>::value. But there's a lot of code uses type traits, so this sort
of thing happens.

gcc 12 tells me:

<source>:8:15: error: function template-id 'some_check<C>' in
nested-name-specifier
    8 | static_assert(some_check<C>::value);
      |               ^~~~~~~~~~~~~
<source>:2:16: note: 'template<class T> constexpr bool some_check()' declared
here
    2 | constexpr bool some_check() {
      |                ^~~~~~~~~~

Now, technically, this is all... correct. You can't use a function template-id
in a nested-name-specifier, and the error does point me to the declaration of
the function template in question which helped me realize my error. 

But it'd be nice to provide this error in less grammatical terms (especially
since the problem here was that I didn't realize some_check was a function
template). Maybe something like:

error: can only access nested names on class types or namespaces, but
some_check is a function template.

This can probably be improved further.

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

* [Bug c++/106354] Diagnostic could be more user friendly
  2022-07-19 13:50 [Bug c++/106354] New: Diagnostic could be more user friendly barry.revzin at gmail dot com
@ 2022-07-19 13:58 ` redi at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: redi at gcc dot gnu.org @ 2022-07-19 13:58 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
   Last reconfirmed|                            |2022-07-19
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

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

end of thread, other threads:[~2022-07-19 13:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-19 13:50 [Bug c++/106354] New: Diagnostic could be more user friendly barry.revzin at gmail dot com
2022-07-19 13:58 ` [Bug c++/106354] " redi 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).