mirror of
https://forge.sourceware.org/marek/gcc.git
synced 2026-02-22 20:01:31 -05:00
The patch for 100111 extended our handling of empty base elision to the case where the derived class has no other fields, but we still need to make sure that there's some initializer for the derived object. PR c++/105245 PR c++/100111 gcc/cp/ChangeLog: * constexpr.cc (cxx_eval_store_expression): Build a CONSTRUCTOR as needed in empty base handling. gcc/testsuite/ChangeLog: * g++.dg/cpp1y/constexpr-empty2.C: Add -fno-elide-constructors.
29 lines
395 B
C
29 lines
395 B
C
// { dg-do compile { target c++14 } }
|
|
// { dg-additional-options -fno-elide-constructors }
|
|
|
|
struct A
|
|
{
|
|
constexpr A(int) { }
|
|
};
|
|
|
|
struct B: A {
|
|
constexpr B(int i): A(i) { }
|
|
constexpr B(const B& b): A(b) { }
|
|
};
|
|
|
|
struct C {
|
|
B b;
|
|
constexpr C(int i): b(i) { }
|
|
constexpr C(const C&c): b(c.b) {}
|
|
};
|
|
|
|
constexpr int f()
|
|
{
|
|
C b1{42};
|
|
C b2{b1};
|
|
b2.b;
|
|
return 42;
|
|
}
|
|
|
|
constexpr int i = f();
|