[Bug c++/86255] New: addition of default argument on redeclaration makes this constructor a default constructor
zhonghao at pku dot org.cn
gcc-bugzilla@gcc.gnu.org
Thu Jun 21 02:18:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86255
Bug ID: 86255
Summary: addition of default argument on redeclaration makes
this constructor a default constructor
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: zhonghao at pku dot org.cn
Target Milestone: ---
The code is as follow:
# 3 "bug3.cc"
class Z {
public:
Z(int);
private:
int i;
};
Z::Z(int j=43): i(j){}
int main()
{
Z zobject=Z();
}
clang++ produces the following errors:
bug3.cc:12:10: error: addition of default argument on redeclaration makes this
constructor a default constructor
Z::Z(int j=43): i(j){}
^ ~~
bug3.cc:7:2: note: previous declaration is here
The code comes from a gcc bug report:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=2189
I reported the difference to clang:https://bugs.llvm.org/show_bug.cgi?id=37850
Richard Smith told me that Clang's diagnostic is correct. So, is this a
recurring bug in g++?
More information about the Gcc-bugs
mailing list