From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E5C3E3858D39; Fri, 20 Oct 2023 14:05:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E5C3E3858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1697810750; bh=V2Aazw6/aTqHNvgV3dMWl6a4zHIYhfiQ2e5+H6k7TZA=; h=From:To:Subject:Date:From; b=gKP1vls7javmCfuTsdMXYLwb2VAJI6cvyhkUWjcPFW9LwW1VlEoMtXntvo/bLc697 WRw4BPEqpUPILNT7ZEj4vF+l3jItTPWf1wDMHSLaFEBsLN4NXZ5EEyh0+CaNqQfLID lIrTwpOpNAI8PJKhWHs61hWRpiS+WAPGEEO52CUk= From: "nabijaczleweli at nabijaczleweli dot xyz" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/111895] New: error: invalid operands of types 'unsigned char:2' and 'int' to binary 'operator!=' Date: Fri, 20 Oct 2023 14:05:50 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: nabijaczleweli at nabijaczleweli dot xyz X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D111895 Bug ID: 111895 Summary: error: invalid operands of types 'unsigned char:2' and 'int' to binary 'operator!=3D' 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 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(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!=3D' 8 | bool func(fields f) { return static_cast(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++ (De= bian 13.2.0-5) 13.2.0".=