Behavior of constructor with default arguments

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?

Regards,
Sniventals and Creeperxie




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux