Skip to content

[C++23] "no return statement in constexpr function" no longer an error with P2448 #92583

Closed
@MitalAshok

Description

@MitalAshok

These:

constexpr int f() {}
static_assert(__is_same(decltype([] constexpr -> int {}()), int));
consteval int g() {}
static_assert(__is_same(decltype([] consteval -> int {}()), int));

Should compile in C++23. It probably still should have a warning diagnostic (the -Wreturn-type "non-void {function|lambda} does not return a value" should be issued for f and g at least), but it shouldn't be an error (https://wg21.link/P2448R2#pnum_24)

Currently, these issue the diagnostic error: no return statement in constexpr/consteval function/lambda

Also #63617 does not apply to C++23

See also: #77753

Metadata

Metadata

Assignees

No one assigned

    Labels

    c++23clang:frontendLanguage frontend issues, e.g. anything involving "Sema"constexprAnything related to constant evaluation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions