[Bug c++/79503] New: [new inheriting ctors] spurious bad candidate from same or derived type
lucdanton at free dot fr
gcc-bugzilla@gcc.gnu.org
Tue Feb 14 07:43:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79503
Bug ID: 79503
Summary: [new inheriting ctors] spurious bad candidate from
same or derived type
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: lucdanton at free dot fr
Target Milestone: ---
My understanding of the new inheriting constructor rules is a bit shaky so I
may be off here. The testcase:
//--------------------
struct payload {};
struct base: private payload {
base(payload) {}
};
struct derived: base {
using base::base;
};
int main()
{
payload data;
// error: no matching function for call to 'derived::derived(payload&)'
// note: candidate: base::base(payload)
// note: an inherited constructor is not a candidate for initialization
from an expression of the same or derived type
derived demo(data);
}
//--------------------
Compilation fails on recent trunk with e.g.:
g++-trunk -std=c++14 main.cpp
but succeeds with -fno-new-inheriting-ctors. A hint that something is wrong is
that there is no error if base derives from some other class than payload.
At the very least the last note is misleading: all inherited candidates are
from base whereas the expression has type payload which is neither the same nor
derived from it.
More information about the Gcc-bugs
mailing list