Open hubert-reinterpretcast opened 7 years ago
Similarly, the virtual base initialization is miscompiled when the constructor is inherited from the direct base (or at least this is about the only interpretation more natural than deeming the program ill-formed).
extern "C" int printf(const char *, ...);
struct A { A(int); A() = default; };
A::A(int x) { printf("%s: %d\n", __PRETTY_FUNCTION__, x); }
struct B : virtual A { };
struct C : B, A { using A::A; };
int main(void) { C c(42); }
Extended Description
When a constructor is inherited from a virtual base and the class from which said constructor is inherited is also a direct base of the complete object being constructed, the initialization of the direct base is supposed to be a default initialization, but Clang seems to treat it like the virtual base.
SOURCE (
<stdin>
):COMPILER INVOCATION:
COMPILER OUTPUT:
(Clean compile)
ACTUAL RUN OUTPUT (
./a.out
):EXPECTED RUN OUTPUT:
COMPILER VERSION INFO (
clang++ -v
):