https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111895

            Bug ID: 111895
           Summary: error: invalid operands of types 'unsigned char:2' and
                    'int' to binary 'operator!='
           Product: gcc
           Version: 13.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nabijaczleweli at nabijaczleweli dot xyz
  Target Milestone: ---

Simplified from other code:
    #include <cstdint>

    enum class o_field : std::uint8_t { no, yes, different_from_s };
    struct fields {
      o_field o : 2;
    };

    bool func(fields f) { return static_cast<bool>(f.o); }
yields
    main.cpp: In function 'bool func(fields)':
    main.cpp:8:50: error: invalid operands of types 'unsigned char:2' and 'int'
to binary 'operator!='
        8 | bool func(fields f) { return static_cast<bool>(f.o); }
          |                                                ~~^

Which is nonsensical. Clang accepts this, and does the expected thing.

Repros on "g++ (GCC) 13.1.0", "g++ (Debian 12.2.0-14) 12.2.0", and "g++ (Debian
13.2.0-5) 13.2.0".

Reply via email to