From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 91567384AB63; Wed, 8 May 2024 22:12:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 91567384AB63 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1715206329; bh=WPTv3zYb3iFT4dKoXkgsuJpax9kgP/m/cpFB553x4DU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=OUQESFAHtXu9tjFjUKWdmxReHOrPOSRoOSKzfDzP7UuJLuyoeI3szFsbG5g13p33K anKRkENRNrVlh/apJdU7MGVolUnsD2fonHHrtyVQ8stSm//+bBAFZsvhcQDCCsR/dR 9RR8vv5j+kamd4Quv7essErWJFFdiHxQ/IXnCV9U= From: "carlosgalvezp at gmail dot com" To: gdb-prs@sourceware.org Subject: [Bug gdb/31331] Wenum-constexpr-conversion should be fixed, soon treated as a hard error Date: Wed, 08 May 2024 22:12:08 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: gdb X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: carlosgalvezp at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31331 --- Comment #35 from Carlos Galvez --- I am back at looking at this with fresh eyes ;)=20=20 Playing a bit with the code I believe these are the 2 main issues at hand: - operator~ on signed types (discussed here, it seems there could be a good= way forward based on the latest suggestion). - These unit tests, which I find problematic: CHECK_VALID (true, int, true ? EF () : EF2 ()) CHECK_VALID (true, int, true ? EF2 () : EF ()) CHECK_VALID (true, int, true ? EF () : RE2 ()) CHECK_VALID (true, int, true ? RE2 () : EF ()) I propose to remove these unit tests (see below why). With that I believe we could make this work. Rationale --------- If I understand correctly, the goal with these unit tests is to make "enum_flags" behave like a regular C enum, in the sense that the expression "true ? enum1() : enum2()" returns an "int". The story about why it returns an "int" is very complicated, but essentially comes from here: https://eel.is/c++draft/expr.cond#7.2 The "usual arithmetic conversions" are applied on the raw enums. Now, reading up on arithmetic conversions, I find: https://en.cppreference.com/w/cpp/language/usual_arithmetic_conversions > If either operand is of enumeration type, and the other operand is of a d= ifferent enumeration type or a floating-point type, the expression is ill-f= ormed. (since C++26) So, this seems to indicate that the above expression will be ill-formed in C++26, and code should no longer compile. GCC is already throwing a warning= at that: https://godbolt.org/ Therefore, I see no reason to keep functionality that will be ill-formed in= the future.=20 Would you be okey with removing those unit tests? --=20 You are receiving this mail because: You are on the CC list for the bug.=