From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9AB6A385842A; Mon, 27 Sep 2021 21:05:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9AB6A385842A From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/102502] C11: _Static_assert disallows const int operand in -O0 while allows it in higher -O Date: Mon, 27 Sep 2021 21:05:04 +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: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Sep 2021 21:05:04 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102502 --- Comment #5 from Jakub Jelinek --- (In reply to Andrew Pinski from comment #4) > (In reply to Jakub Jelinek from comment #2) > > Why do you think it is a bug? >=20 > Because there were other bugs which were fixed where there was an > inconsistency, PR 66618, and PR 71983 for an example. There are others. >=20 > Oh there is an inconsistency when the _Static_assert is not in a function= vs > inside a function. > Take: > static const int allocation_size =3D 32768; > _Static_assert (allocation_size, ""); > void f(void) { _Static_assert(allocation_size, ""); } >=20 > The assert inside the function is accepted at -O1 but reject at -O0 while > the one outside is always rejected. But it is an intentional decision, to match the previous behavior in that a= rea plus handle what was needed.=