Skip to content

return-type deduction failure for lambda inside decltype. #168249

@jehelset

Description

@jehelset

This fails to compile on clang-trunk.

template<int I>
using X = decltype(
    []{
        if constexpr(I == 0)
            return int{};
        else
            return char{};
    }()
);

template<int I>
inline constexpr auto Y = X<I>{};

static_assert(Y<1> == char{});

Need to inject a template-param () for it to work.

Works on gcc. Godbolt: https://godbolt.org/z/3Ydv8b866.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"diverges-from:gccDoes the clang frontend diverge from gcc on this issuelambdaC++11 lambda expressions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions