On Sat, 1 Feb 2025 at 11:41, Jonathan Wakely <jwakely.gcc@xxxxxxxxx> wrote: > > On Sat, 1 Feb 2025 at 08:59, Creeperxie via Gcc-help > <gcc-help@xxxxxxxxxxx> wrote: > > > > Dear list, > > > > I would like to discuss the behavior of constructors with default > > arguments in > > GCC. > > > > In Clang, if a constructor redeclared with a default argument, it throws an > > error, indicating the constructor has become a default constructor. The > > early > > detection helps prevent potential issues for users. > > > > Here is an example to illustrate the issue. > > > > class Example { > > Example(int arg); > > Example(float arg); > > }; > > > > Example::Example(int arg = 0) { > > } > > > > Example::Example(float arg = 0) { > > } > > > > When compiled with Clang, the following error is generated: > > > > error: addition of default argument on redeclaration makes this > > constructor a default constructor > > > > Will GCC consider implementing a similar warning for this situation? > > Please file a bug https://gcc.gnu.org/bugs > > In C++11 the code above was valid, but it's ill-formed since C++14. It > looks like GCC never implemented that change. Actually we already have a bug report about it: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58194