[llvm-bugs] [Bug 38325] New: decltype for lambda capture gives wrong type

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jul 26 01:19:30 PDT 2018


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

            Bug ID: 38325
           Summary: decltype for lambda capture gives wrong type
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: antoshkka at gmail.com
                CC: llvm-bugs at lists.llvm.org

According to my reading of the http://eel.is/c++draft/expr.prim.id.unqual#2 the
following code should compile:

#include <type_traits>
#include <cassert>

constexpr std::true_type  is_const(int const &)   { return {}; }
constexpr std::false_type is_const(int &)         { return {}; }

int main() {
  int x = 0;
  [y = x, x] {
    const int z = 0;
    assert(is_const(x)); // OK
    assert(is_const(y)); // OK
    assert(is_const(z)); // OK

    static_assert(!decltype(is_const(x))::value, "");
    static_assert(decltype(is_const(y))::value, ""); // Fails (OK on GCC)
    static_assert(decltype(is_const(z))::value, "");

    static_assert(!std::is_const<decltype(x)>::value, "");
    static_assert(std::is_const<decltype(y)>::value, ""); // Fails (OK on GCC)
    static_assert(std::is_const<decltype(z)>::value, "");
  } ();
}

However, two lines marked with "Fails (OK on GCC)" do not pass the asserts.

-- 
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/20180726/6f5d4034/attachment.html>


More information about the llvm-bugs mailing list