public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/111895] New: error: invalid operands of types 'unsigned char:2' and 'int' to binary 'operator!='
@ 2023-10-20 14:05 nabijaczleweli at nabijaczleweli dot xyz
  2023-10-20 15:19 ` [Bug c++/111895] error: invalid operands of types 'unsigned char:2' and 'int' to binary 'operator!=' on enum class bitfield cast to bool redi at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: nabijaczleweli at nabijaczleweli dot xyz @ 2023-10-20 14:05 UTC (permalink / raw)
  To: gcc-bugs

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".

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-02-01 22:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-20 14:05 [Bug c++/111895] New: error: invalid operands of types 'unsigned char:2' and 'int' to binary 'operator!=' nabijaczleweli at nabijaczleweli dot xyz
2023-10-20 15:19 ` [Bug c++/111895] error: invalid operands of types 'unsigned char:2' and 'int' to binary 'operator!=' on enum class bitfield cast to bool redi at gcc dot gnu.org
2023-10-20 22:08 ` mpolacek at gcc dot gnu.org
2023-10-23 20:34 ` mpolacek at gcc dot gnu.org
2023-10-25  0:23 ` cvs-commit at gcc dot gnu.org
2024-02-01 22:20 ` mpolacek at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).