8sa1-gcc/gcc/testsuite/g++.dg/cpp0x/constexpr-empty14.C
Jason Merrill 8fda2c274a c++: Allow parm of empty class type in constexpr.
Since copying a class object is defined in terms of the copy constructor,
copying an empty class is OK even if it would otherwise not be usable in a
constant expression.  Relatedly, using a parameter as an lvalue is no more
problematic than a local variable, and calling a member function uses the
object as an lvalue.

	PR c++/91953
	* constexpr.c (potential_constant_expression_1) [PARM_DECL]: Allow
	empty class type.
	[COMPONENT_REF]: A member function reference doesn't use the object
	as an rvalue.
2020-02-03 17:50:36 -05:00

11 lines
128 B
C

// PR c++/91953
// { dg-do compile { target c++11 } }
struct S {};
template <class T> void
foo (S s)
{
constexpr S x = s;
}