A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/cplusplus/CWG/issues/550 below:

CWG2906 [expr.cond], [expr.const] Lvalue-to-rvalue conversion of class types disqualifies constant expressions · Issue #550 · cplusplus/CWG · GitHub

Reference (section label): [expr.cond], [expr.const]

Issue description

In some situations, the lvalue-to-rvalue conversion mandated by [expr.cond] paragraph 7 can apply to class types. Such lvalue-to-rvalue conversions may not be constant expressions (see [expr.const] paragraph 5, bullet 9) even though they result in a call to the copy constructor ([conv.lval] paragraph 3, bullet 2), and calling the copy constructor directly would be a constant expression.

struct S {};
S a;
constexpr S b = a;                // OK, call to implicitly-declared copy constructor
S c           = false ? S{} : a;  // OK, call to copy constructor through lvalue-to-rvalue conversion of 'a'
constexpr S d = false ? S{} : a;  // error: lvalue-to-rvalue conversion of 'a' is not a constant expression

None of MSVC, GCC, or Clang implement this behavior and permit constexpr S d = false ? S{} : a; instead.

Suggested resolution

The use of lvalue-to-rvalue conversion in [expr.cond] may be eliminated for class types.

Alternatively, update [expr.const] to permit this case.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4