From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0082B3858D39; Sun, 11 Feb 2024 20:40:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0082B3858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1707684005; bh=2aSYHE7B6XPyvmv8G6/gbbYJ01bQq9z+coKRy/KE7FU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=mZVyg0Qa3vJq+F96EnsS3ss2YKp7LAKr4IEDNm9oA3+yUDtiMBL7FIPkwwLnHjEsT +SephShBOT++fp2KqLOnRq2DkJBh9ZwjTOKajPFGSKPEit1rVdtKEx/kdx5QNagNKK ZCc1Gg9LVuTmg9hW03tGD2sflzkOAt6m3JNFEEmY= 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: Sun, 11 Feb 2024 20:40:04 +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: 15.1 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 #29 from Carlos Galvez --- Hmm, applying Aaron's suggestion above, I found what I believe to be a bug. With this change: +template +struct enum_decays_to_signed +{ + static constexpr bool value =3D std::is_signed_v() : std::declval>())>; +}; + 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>::type type; D I get: ./dwarf2/cooked-index.h:212:22: error: use of deleted function =E2=80=98con= stexpr void operator~(enum_type) [with enum_type =3D cooked_index_flag_enum; =3D void; =3D void]=E2=80= =99 212 | flags =3D flags & ~IS_PARENT_DEFERRED; | ^~~~~~~~~~~~~~~~~~ This is because that enum has an underlying type of "unsigned char": enum cooked_index_flag_enum : unsigned char Unsigned char does decay/promote to signed integer when performing arithmet= ic on it: https://godbolt.org/z/Tfv7e3f8Y So current master is allowing operator~ on an enum of type unsigned char, w= hich will decay to signed int before applying operator~ (which is what we want to avoid, since bitwise operations shall be performed on unsigned types only). --=20 You are receiving this mail because: You are on the CC list for the bug.=