https://bugs.llvm.org/show_bug.cgi?id=35423

            Bug ID: 35423
           Summary: decltype((x)) inside lambda is considered odr-use if x
                    is captured
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangb...@nondot.org
          Reporter: dea...@gmail.com
                CC: dgre...@apple.com, llvm-bugs@lists.llvm.org

https://godbolt.org/g/NmA3ZP

#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."

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to