From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 148D1382EF10; Thu, 24 Nov 2022 19:29:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 148D1382EF10 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669318142; bh=5h44rrhlEF4ub3pTuaO8tlbB3haJrKQa8AaZiGbjQc4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=JZtGQJ2ByrG968e1BXbYPAu8lbH1E7O1z8X2iBVx/zXC4QiVShdgxNfVlfomqSBJD XZWwXkdlUrQZWubNdpT25yh5juuluqGvCsju9qcr6AjNoWhvyRADTUXCjB30TrulEl gTQbO4X9wo7zOJdTu2ioDc1M5FiDmAbF+hgT5hro= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107861] C++ static_assert() does not honor -fwrapv, leading to compilation error Date: Thu, 24 Nov 2022 19:29:01 +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: 12.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: redi 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=3D107861 --- Comment #4 from Jonathan Wakely --- Andrew is right. The C++ standard says this is ill-formed, the -fwrapv opti= on isn't allowed to change that. The option means that runtime overflow is well-defined instead of undefined, but that doesn't change static compile-time behaviour that is ill-formed. Overflow in constant expressions and template arguments is still an error, = even if the arithmetic would wrap at runtime.=