From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0F1DF3858C5E; Fri, 11 Nov 2022 15:07:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0F1DF3858C5E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668179260; bh=/Vf/D6dlPV7mT8JJviR06Uh87JBIJRh0gwxwVoe9Kzw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=SbOhcQD/hSCb18MlIhgYmD3zGY7cLtSO6lpuq4c90BZcAt5B/oo50Tg1BXDou9BuX vHfmvBCPt5zN4SEI7mDIXRP/yWXO2iCNqUw5+CT+uWaKMDo+Q1vFCDwEaxrlDg32S2 hVORXALZNEleY9zcFMc7aY3yYdzcL9uYKAwldg4c= From: "glisse at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107622] Missing optimization of switch-statement Date: Fri, 11 Nov 2022 15:07:39 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: glisse at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.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://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107622 --- Comment #7 from Marc Glisse --- (Wilhelm, when you post testcases, please post the full file including the #include lines) (In reply to Richard Biener from comment #5) > Did you try -fstrict-enums? IIUC, even if optimizations using -fstrict-enums were implemented, they wou= ld only help with the first testcase if the number of enum values was a power = of 2. For {A,B,C}, -fstrict-enums still considers 3 a valid value. I have long wanted an attribute to specify that a particular enum is only allowed to take the values explicitly listed, though I cannot find a releva= nt issue in bugzilla at the moment. Comment #4 is an independent issue where gcc fails to notice that since the static variable does not escape, it can be replaced with a local constant.=