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

            Bug ID: 114845
           Summary: Confusing message when using undeclared identifier of
                    Const
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hewillk at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/v6M35zMa4

There is a typo here, I missed an underscore:

template<bool Const__> requires Const_
struct S;

S<true> s;

The error message reported by Clang is:

<source>:1:33: error: use of undeclared identifier 'Const_'; did you mean
'Const__'?
    1 | template<bool Const__> requires Const_
      |                                 ^~~~~~
      |                                 Const__

which is clear and corrects my typo. However, the error given by GCC is:

<source>:4:7: error: 'Const_' was not declared in this scope; did you mean
'const'?
    4 | S<true> s;
      |       ^
      |       const

First, the cursor points to 'S<true> s', and there is no identifier name
'Const_' here.
Second, in context, I definitely do not mean the keyword 'const' because
'requires const' makes no sense.

Reply via email to