[Bug c++/87234] GCC should warn if template parameter redefines default argument

2019-06-04 Thread ghleclerc at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87234

Ghyslain Leclerc  changed:

   What|Removed |Added

 CC||ghleclerc at gmail dot com

--- Comment #1 from Ghyslain Leclerc  ---
Created attachment 46448
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46448&action=edit
Output from g++ command.

Compiler output with the command
   g++-mp-9 -v -save-temps -std=c++11 bug.cpp 2> out.txt

[Bug c++/87234] GCC should warn if template parameter redefines default argument

2019-06-04 Thread ghleclerc at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87234

--- Comment #2 from Ghyslain Leclerc  ---
I wanted to add that on top of not complaining about the default parameter
redefinition, when the default parameter is provided in the definition only
(not the declaration of the template), the compilation fails.

Here is the snippet of code I used to have the bug.  Since it does not contain
any includes and the preprocessed file is basically the same, I think it's OK
to just have the code here.


template< typename T, unsigned int TSz >
T mul( T num );

template< typename T, unsigned int TSz = sizeof( T ) >
T mul( T num ) {
  return num * TSz;
}

int main() {
  return mul( 5 );
}


Given this code, the compiler fails to compile and outputs an error.  I have
done as recommended on the bug reporting page and gotten all the output.  I
will attach the files to this bug report.  Hoping it's OK.  It seems like the
two bugs might be the same or at least related.