From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 45D16382FCB0; Thu, 24 Nov 2022 17:25:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 45D16382FCB0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669310733; bh=9HZ0/gK70s0dxIhrHVSm+kwFIdSYOVRG6l4UUsRXJm4=; h=From:To:Subject:Date:From; b=k4eLkKXmTrq+Pu7J9Gc03n+6/2h8aOKyGVC9RJTIFSHutRHkSPh3RnGCKMRVAf+Hj 2YoJhwpvkSVgNo3qNMaFUq4VyYR8Jk9bAHgbjIOejrwb4+9bvRq3bSC4W+SFLoo59Z SrePRxqQLAI8qXmkKcB3iB2CDuBsWumNGPTSrd8I= From: "markus at oberhumer dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107861] New: C++ static_assert() does not honor -fwrapv, leading to compilation error Date: Thu, 24 Nov 2022 17:25:32 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: markus at oberhumer dot com 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D107861 Bug ID: 107861 Summary: C++ static_assert() does not honor -fwrapv, leading to compilation error Product: gcc Version: 12.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: markus at oberhumer dot com Target Milestone: --- C++ static_assert() does not honor -fwrapv, leading to compilation error godbolt link: https://gcc.godbolt.org/z/Po8vc5Kex $ g++ --version g++ (GCC) 12.2.1 20220819 (Red Hat 12.2.1- $ g++ -fwrapv -Wno-overflow -c test.cpp test.cpp:7:34: error: non-constant condition for static assertion $ cat test.cpp // compile with: g++ -fwrapv -Wno-overflow -c test.cpp // // extra rant: -Wno-overflow should not be needed here! #include #define wrap_inc(x) ((x) + 1 < (x)) constexpr int int_max =3D INT_MAX; bool b0 =3D wrap_inc(int_max); const bool b1 =3D wrap_inc(int_max); constexpr bool b2 =3D wrap_inc(int_max); static_assert(b2, ""); // works // error: non-constant condition for static assertion static_assert(wrap_inc(int_max), "");=