[Bug c++/95659] Inconsistent error message in "default argument missing for parameter"

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Jun 18 11:34:42 GMT 2020


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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Haoxin Tu from comment #0)
> $cat bug.cc
> int a;
> long  foo1 ( void  = a, double  param2 ,decltype (auto) param3 = a){ }
> long  foo2 ( void  = a, double  param2){ }
> 
> In gcc-trunk
> $g++-trunk -w -c -std=c++14 bug.cc 
> bug.cc:2:41: error: cannot declare a parameter with ‘decltype(auto)’
>     2 | long  foo1 ( void  = a, double  param2 ,decltype (auto) param3 = a){
> }
>       |                                         ^~~~~~~~~~~~~~~
> bug.cc:2:14: error: invalid use of type ‘void’ in parameter declaration
>     2 | long  foo1 ( void  = a, double  param2 ,decltype (auto) param3 = a){
> }
>       |              ^~~~~~~~~

The first two errors are correct, the function declaration is complete garbage
and these errors correctly identify some of the problems.

Whether it *also* notices another error in this garbage doesn't really matter.
You need to fix this nonsense before the code can be compiled anyway.

The general rule of thumb is always to start by fixing the first errors,
because they might be causing the later ones. If you fix those two errors, then
G++ will  tell you about the next problem.

It's not really helpful to keep pointing out that if you randomly generate
complete garbage then GCC gets confused.


More information about the Gcc-bugs mailing list