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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-07-22
             Status|UNCONFIRMED                 |NEW
           Keywords|accepts-invalid             |diagnostic
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The 'auto' parameter makes this a function template, and you never instantiate
the template. Compilers are not required to diagnose errors in uninstantiated
templates.

If you call it, you get the expected error:

void 
foo (auto,
    int var = throw )
{}

int main()
{
  foo(1);
}


96183.C: In function ‘void foo(auto:1, int) [with auto:1 = int]’:
96183.C:3:15: error: could not convert ‘<throw-expression>’ from ‘void’ to
‘int’
    3 |     int var = throw )
      |               ^~~~~
      |               |
      |               void
96183.C:8:6: note:   when instantiating default argument for call to ‘void
foo(auto:1, int) [with auto:1 = int]’
    8 |   foo(1);
      |   ~~~^~~
96183.C: In function ‘int main()’:
96183.C:8:6: error: void value not ignored as it ought to be

The second error seems bogus though.


Confirming as a diagnostic bug, but it's not accepts-invalid.

Reply via email to