From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 76B7B3858C29; Mon, 5 Feb 2024 20:08:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 76B7B3858C29 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1707163686; bh=zlG0gzUrQ3YLx2FJNhGtaxtqk+RffR/KsqN7TuPwaNk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=pGTHP+4Tdx3AVO/orGek/C6o1+IqTv0qIUpVqHQwW2SCYQkMfDRdLTnX/YEE9aBM3 jsup5OQJpLleXn80Lk98yBoZbYzNRPGb8g8u1rxc83kF54HNdVg4gmIZKl3eQ8xDEj IAf+pBGNFVnicoBV5Q5QeFKOdOSOScHvZWnqreko= From: "simon.marchi at polymtl dot ca" To: gdb-prs@sourceware.org Subject: [Bug gdb/31331] Wenum-constexpr-conversion should be fixed, soon treated as a hard error Date: Mon, 05 Feb 2024 20:08:06 +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: simon.marchi at polymtl dot ca 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 #16 from Simon Marchi --- (In reply to Carlos Galvez from comment #9) > > If I change the enum_underlying_type definition to be: >=20 > That's exactly what I had in mind to change it to. You mention this change > keeps the current behavior and the operator overload works as expected. Is > there anything else that breaks? So, with that change, for the enums that don't specify an underlying type, enum_flags::underlying_type would go from a signed type to an unsigned one. I didn't spot it at first, but another spot that uses the underlying type is the definition of the binary bitwise operators, using this template: https://gitlab.com/gnutools/binutils-gdb/-/blob/68d3bf7d246321407697aeb0360= 36dae1a99a742/gdbsupport/enum-flags.h#L226-333 /* Raw enum on both LHS/RHS. Returns raw enum type. */ \ template > \ constexpr enum_type \ OPERATOR_OP (enum_type e1, enum_type e2) \ { \ using underlying =3D typename enum_flags::underlying_type; \ return (enum_type) (underlying (e1) OP underlying (e2)); \ } \ So we will cast the enum values to an unsigned type rather than a signed ty= pe before applying the operator. I don't really see how things can go wrong wi= th that in practice. --=20 You are receiving this mail because: You are on the CC list for the bug.=