Skip to content

[Clang] C23 struct compatiblity rule differs from GCC #141724

Closed
@fuhsnn

Description

@fuhsnn

The last case shows that clang-21 currently treat two same-record structs without tag as compatible, while GCC doesn't.

struct     {int i;} nontag;
struct tag {int i;} tagged;

static_assert(1 == _Generic(tagged, struct tag {int i;}:1, default:0)); // both 1
static_assert(0 == _Generic(tagged, struct     {int i;}:1, default:0)); // both 0
static_assert(0 == _Generic(nontag, struct tag {int i;}:1, default:0)); // both 0
static_assert(0 == _Generic(nontag, struct     {int i;}:1, default:0)); // gcc:0 clang:1

https://godbolt.org/z/bGWfYT5WE

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepts-invalidc23clang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second party

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions