[llvm-bugs] [Bug 35423] New: decltype((x)) inside lambda is considered odr-use if x is captured
    via llvm-bugs 
    llvm-bugs at lists.llvm.org
       
    Sun Nov 26 01:48:56 PST 2017
    
    
  
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: unassignedclangbugs at nondot.org
          Reporter: deaeod at gmail.com
                CC: dgregor at apple.com, llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20171126/ad2c7a2a/attachment.html>
    
    
More information about the llvm-bugs
mailing list