Skip to content

is_constant_evaluated can evaluate to false in static class member initializer #99680

Closed
@efriedma-quic

Description

@efriedma-quic

Testcase:

#include <type_traits>
struct X { static const int x = 1/(1-std::is_constant_evaluated()); };
int z[X::x];

gcc and MSVC correctly error; clang somehow evaluates it to 1. It looks like clang somehow falls back on non-constant-context evaluation in some cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions