https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105550
Bug ID: 105550 Summary: Missing copy elision with conditional operator in NSDMI Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mpolacek at gcc dot gnu.org Target Milestone: --- Consider: struct A { const A* p = this; }; struct E { A a = true ? A{} : A{}; }; constexpr E e{}; $ ./cc1plus -quiet q.C q.C:9:15: error: ‘E{A{((const A*)(&<anonymous>))}}’ is not a constant expression 9 | constexpr E e{}; | ^ The ?: shouldn't preclude copy elision. 'e' must be static for this to work. Bug 96004 with a similar title doesn't seem to be a duplicate of this one.