Hi! I admit this is just a shot in the dark, but I don't see why one couldn't adjust a type of EMPTY_CLASS_EXPR to EMPTY_CLASS_EXPR with a different variant of the same type.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? Or, should I drop that && TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (TREE_TYPE (temp)) part? We don't really verify something similar for CONSTRUCTORs. 2018-11-16 Jakub Jelinek <ja...@redhat.com> PR c++/87506 * constexpr.c (adjust_temp_type): Handle EMPTY_CLASS_EXPR. * g++.dg/cpp0x/constexpr-87506.C: New test. --- gcc/cp/constexpr.c.jj 2018-11-16 10:22:18.668258171 +0100 +++ gcc/cp/constexpr.c 2018-11-16 19:24:13.564095334 +0100 @@ -1281,6 +1281,9 @@ adjust_temp_type (tree type, tree temp) /* Avoid wrapping an aggregate value in a NOP_EXPR. */ if (TREE_CODE (temp) == CONSTRUCTOR) return build_constructor (type, CONSTRUCTOR_ELTS (temp)); + if (TREE_CODE (temp) == EMPTY_CLASS_EXPR + && TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (TREE_TYPE (temp))) + return build0 (EMPTY_CLASS_EXPR, type); gcc_assert (scalarish_type_p (type)); return cp_fold_convert (type, temp); } --- gcc/testsuite/g++.dg/cpp0x/constexpr-87506.C.jj 2018-11-16 19:32:28.854867665 +0100 +++ gcc/testsuite/g++.dg/cpp0x/constexpr-87506.C 2018-11-16 19:32:04.705268812 +0100 @@ -0,0 +1,12 @@ +// PR c++/87506 +// { dg-do compile { target c++11 } } + +struct A {}; +struct B { constexpr B (const A) {} }; +struct C : B { using B::B; }; + +void +foo () +{ + C c (A{}); +} Jakub