Skip to content

[Clang] Comparison between pointers to a string literal and some other object results in constant evaluation failure #92382

@frederick-vs-ja

Description

@frederick-vs-ja

The following code snippet is incorrectly rejected by Clang (Godbolt link).

static_assert([]{
    char arr[1]{};
    return arr != "a";
}());

arr is not a potentially non-unique object, so it must have a different address from that of string literal object "a", even though the latte is a potentially non-unique object. As a result, arr != "a" has a specified result (true), so the static assertion should be accepted.

#49380 is related. But that issue involved comparison between pointers to different string literal objects, where it's very non-trivial to determine whether the result is unspecified.

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