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

            Bug ID: 109799
           Summary: *= used in a declaration when trying to do default
                    argument with a pointer type could give a better error
                    message
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take:
```
int f(int*=nullptr);
```
Currently GCC gives not so helpful error message:
<source>:1:10: error: expected ',' or '...' before '*=' token
    1 | int f(int*=nullptr);
      |          ^~


I was trying to figure out what I did wrong before I realized that `*=` is a
single token and there needs to be white space between the `*` and the `=`. GCC
could figure out that `*=` usage in this context was supposed to be the two
token version. 

Note clang gives an even worse error message:
<source>:1:10: error: expected ')'
int f(int*=nullptr);
         ^
<source>:1:6: note: to match this '('
int f(int*=nullptr);
     ^

Reply via email to