Issue 83712
Summary [expr.const] lvalue-to-rvalue conversion is not diagnosed
Labels new issue
Assignees
Reporter Eisenwave
    https://godbolt.org/z/KnPx1ejbb
```cpp
struct S {};

constexpr int f(S s) {
    constexpr S _ = s;
    return 0;
}

S s;
constexpr int _ = f(s);
```
This code compiles, but should produce errors for both `constexpr` initializations.

According to [[expr.const] p5.9](http://eel.is/c++draft/expr.const#5.9), the initializers of `_` cannot be constant _expression_ because they contain lvalue-to-rvalue conversion of `s`, whose lifetime did not begin within the evaluation of the constant _expression_.

It shouldn't matter whether `S` is an empty class or has members; the lvalue-to-rvalue conversion in itself disqualifies expressions from being constant expressions.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to