Skip to content

decltype for lambda capture gives wrong type #37673

Closed as not planned
Closed as not planned
@apolukhin

Description

@apolukhin
Bugzilla Link 38325
Version trunk
OS Linux
CC @apolukhin,@dwblaikie,@egorpugin,@zygoloid

Extended Description

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

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclang:frontendLanguage frontend issues, e.g. anything involving "Sema"invalidResolved as invalid, i.e. not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions