From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 652D73858C2F; Mon, 5 Feb 2024 20:55:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 652D73858C2F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1707166523; bh=s/gNt+94OHkqhUouv86PewVhjURRz+uLD4mPQnYzL7E=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Jx67bXTFHAXxRMrD0/qpjjVSLbKZBEw2yMpLUygCEeeFMcbwqinHlHVIlIl4XC08D afLlVAcm6DKWxNdm9Q5NHhLE3p6ni7ctP2QHYBmuv5ohc6gXMVdpsiKvsgIOyqF/sK /pOn/+DmFCuIelOWGjL1YkiSO+aGCFI/NO5ubDHY= 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: Mon, 05 Feb 2024 20:55:23 +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 #20 from Carlos Galvez --- > perhaps some language guru can explain why This is integer promotion when performing arithmetic: https://timsong-cpp.github.io/cppwp/n4140/expr.unary.op#10 The first type towards which the enum is promoted to is "int", as long as t= he values in the enum fit inside an int, otherwise unsigned int. https://timsong-cpp.github.io/cppwp/n4140/conv.prom#3 The same behavior happens when e.g. operating two uint8_t together -> the compiler first converts each uint8_t to "int", then performs the operation = as a signed integer, and finally the result is cast what the user specifies. This can cause subtle bugs (bitwise arithmetic is not recommended on signed integers). --=20 You are receiving this mail because: You are on the CC list for the bug.=