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.
11 lines
128 B
C
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;
|
|
}
|