Skip to content

[Clang] constant evaluation should reject reinterpret_casting arbitrary addressesΒ #154024

@philnik777

Description

@philnik777

Clang currently accepts

#define fold(x) (__builtin_constant_p(x) ? (x) : (x))
constexpr int* x = fold((int*)123);

It looks like this has been added for GCC compatibility over a decade ago. However, GCC rejects this since version 7: https://godbolt.org/z/qMoK83dfP. I don't see a good reason this should be accepted, especially since GCC has started rejecting it a long time ago by now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang: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