Description
Bugzilla Link | 35423 |
Resolution | INVALID |
Resolved on | Dec 16, 2017 08:59 |
Version | trunk |
OS | All |
Reporter | LLVM Bugzilla Contributor |
CC | @dwblaikie,@DougGregor,@zygoloid |
Extended Description
#include <type_traits>
int main() {
int x = 1;
int&& y = static_cast<int&&>(x);
auto A = []{ static_assert(std::is_same_v<decltype((x)), int&>); };
auto B = [=]{ static_assert(std::is_same_v<decltype((x)), int&>); };
auto C = []{ static_assert(std::is_same_v<decltype((y)), int&>); };
auto D = [=]{ static_assert(std::is_same_v<decltype((y)), int&>); };
}
I expected this to compile cleanly, but static asserts B and D fail under clang.
Here is how i would argue for my expectation:
http://eel.is/c++draft/expr.prim.lambda#capture-11.sentence-3
-- "An id-expression that is not an odr-use refers to the original entity, never to a member of the closure type."
http://eel.is/c++draft/basic.def.odr#def:potentially_evaluated
-- "An expression is potentially evaluated unless it is an unevaluated operand or a subexpression thereof."
http://eel.is/c++draft/basic.def.odr#def:odr-used
-- "A variable x whose name appears as a potentially-evaluated expression ex is odr-used by ex unless [...]"
http://eel.is/c++draft/dcl.type.simple#4.sentence-3
-- "The operand of the decltype specifier is an unevaluated operand."