From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id F13BF384F011; Sat, 12 Nov 2022 12:04:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F13BF384F011 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668254662; bh=HQwLLfWU989fC45bmNnh+TM3NNbXEEYAsotq/z5PqM8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=j+sY+kLpTsfXtnsGu6g5LEGx01mrdmvAd6zN7BzavS9opIYyGuVpU67d7h+F6ycWI OTaCzUwMXPIbaUi7TgV/k9Kzfxpinbt/IMSDvAiUkARGj+5bU1uLaWWzSG28fHVLLo 8/tqJbnOcB9fowKHNMtGnOCHufUot2nkM3KgKg7o= From: "yann at droneaud dot fr" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107104] semantics of __builtin_constant_p within static_assert and return value Date: Sat, 12 Nov 2022 12:04:22 +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: unknown X-Bugzilla-Keywords: accepts-invalid X-Bugzilla-Severity: normal X-Bugzilla-Who: yann at droneaud dot fr 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: cc 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=3D107104 Yann Droneaud changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |yann at droneaud dot fr --- Comment #3 from Yann Droneaud --- I'm experiencing the same issue: #include void a(int v) { static_assert(__builtin_constant_p(v) && v =3D=3D -1, "failure"); } GCC 13 and below complains: : In function 'a': :16:43: error: expression in static assertion is not constant 16 | static_assert(__builtin_constant_p(v) && v =3D=3D -1, "fail= ure"); | ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~ Compiler returned: 1 clang current trunk, eg above 15.0, seems to finally get it right: :16:5: error: static assertion failed due to requirement '__builtin_constant_p(v) && v =3D=3D -1': failure static_assert(__builtin_constant_p(v) && v =3D=3D -1, "failure"); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/assert.h:143:24: note: expanded from macro 'static_assert' # define static_assert _Static_assert ^ 1 error generated. Compiler returned: 1 see https://godbolt.org/z/KKn6xTG8a=