Skip to content

[Clang] C11 _Generic matches anything with void in trunk build #141549

Closed
@fuhsnn

Description

@fuhsnn

The static asserts below fail with GCC and Clang <= 20, but pass in Godbolt trunk and clang-21 from Debian nightly repo

_Static_assert(1 == _Generic((int)0 , void : 1),"");
_Static_assert(1 == _Generic((float)0 , void : 1),"");
_Static_assert(1 == _Generic((void*)0 , void : 1),"");
_Static_assert(1 == _Generic((int[4]){}, void : 1),"");

_Static_assert(4 == _Generic(42, void: 4, int: 2),"");
_Static_assert(2 == _Generic(42, int: 2, void: 4),"");

_Static_assert(4 == _Generic(42, void: 4),"");
_Static_assert(2 == _Generic(42, int: 2),"");

Godbolt: https://godbolt.org/z/he9xYrPxq

Metadata

Metadata

Assignees

No one assigned

    Labels

    c2yclang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second partyregression

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions