Skip to content

Default comparision operator + zero-sized bit field cause crash in Clang 14 / 15 #61417

@ppavel96

Description

@ppavel96

Sample code: https://godbolt.org/z/bW71vGW1G

#include <iostream>

class Test {
private:
    unsigned A_: 1;
    unsigned   : 0;

public:
    inline Test()
        : A_(0)
    {
    }

    bool operator==(const Test& rhs) const noexcept = default;
};

int main() {
    Test a, b;
    std::cout << unsigned(a == b) << '\n';
}

Versions prior to 14 do not crash but result is incorrect (and it does not look to me like something that should cause undefined behaviour)

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second partycrash-on-valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions