From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9A232386F802; Fri, 10 May 2024 20:35:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9A232386F802 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1715373301; bh=KuJLNd/FRc1jVNj7IvYNDdzgKY1vZ2rWJFjkaH+uYjc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=POyGA3Vv4u639g9rgjslDExpJDKrOA2Y1M5yWH1dEDkrOpNgToL54N2SWLq+cFUYD 9ZM1S89HwTPmmBZAC7N7CLHnXwkxV/raZK8AUhr3JsRENpSh+khjTWD1wDeTiWtOfT kt1iiaeg3BEAQdEOhgeU70rQLDZnosXK5NAqT3BQ= 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: Fri, 10 May 2024 20:35:01 +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 #36 from Carlos Galvez --- Applying the following diff I believe I can maintain the current behavior without changing any tests. It also serves as documentation of what exactly= it does. I've run the test suite a few times and don't notice a change in the numbers, but of course it'd be great if someone more experienced tests this. I also confirm that we still get a compiler error as requested in comment #= 4. With this in place one can look into refactoring/redesigning to avoid having this at all, hopefully it should be easier to understand. Let me know what you think! --- a/gdbsupport/enum-flags.h +++ b/gdbsupport/enum-flags.h @@ -88,15 +88,26 @@ template<> struct integer_for_size<2, 1> { typedef int1= 6_t type; }; template<> struct integer_for_size<4, 1> { typedef int32_t type; }; template<> struct integer_for_size<8, 1> { typedef int64_t type; }; +template +struct enum_will_be_promoted_to_signed_integer +{ + static constexpr bool value =3D std::is_signed::value; +}; + +template +struct enum_has_underlying_small_integer +{ + static constexpr bool value =3D sizeof(T) < sizeof(int); +}; + template struct enum_underlying_type { - DIAGNOSTIC_PUSH - DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION typedef typename - integer_for_size(T (-1) < T (0))>::type + integer_for_size::value && + !enum_has_underlying_small_integer::value>::type type; - DIAGNOSTIC_POP }; --=20 You are receiving this mail because: You are on the CC list for the bug.=