From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 52130398600E; Fri, 11 Sep 2020 07:47:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 52130398600E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1599810465; bh=c6yvue7yZjV2n8go+eBaDkVGVK9algqUHIr06ugnTeA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=gWNDCw2fYKa6cUJQQd9GKVHPgnQ6VWn01QvhJfbkN7vz11+VZ6yLZdJvvwWA9x5W1 THpmaNEQDvppB9ivwpgL4lSAwQtPrnprkPOWFKGGLt3dKDG7/Y0AM0uvtameem2yRE 2pMheX9OF09npgeu1GY7M47hi5CNt0dTF+3YQiXY= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/96862] -frounding-math -std=c++2a error: '(1.29e+2 * 6.9314718055994529e-1)' is not a constant expression Date: Fri, 11 Sep 2020 07:47:45 +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: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit 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: Fri, 11 Sep 2020 07:47:45 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96862 --- Comment #11 from CVS Commits --- The releases/gcc-10 branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:38a13f9f70c2a60d831dd03a9bfc2e58bd80d888 commit r10-8731-g38a13f9f70c2a60d831dd03a9bfc2e58bd80d888 Author: Jakub Jelinek Date: Thu Sep 3 20:11:43 2020 +0200 c++: Disable -frounding-math during manifestly constant evaluation [PR96862] As discussed in the PR, fold-const.c punts on floating point constant evaluation if the result is inexact and -frounding-math is turned on. /* Don't constant fold this floating point operation if the result may dependent upon the run-time rounding mode and flag_rounding_math is set, or if GCC's software emulation is unable to accurately represent the result. */ if ((flag_rounding_math || (MODE_COMPOSITE_P (mode) && !flag_unsafe_math_optimizatio= ns)) && (inexact || !real_identical (&result, &value))) return NULL_TREE; Jonathan said that we should be evaluating them anyway, e.g. conceptual= ly as if they are done with the default rounding mode before user had a ch= ance to change that, and e.g. in C in initializers it is also ignored. In fact, fold-const.c for C initializers turns off various other option= s: /* Perform constant folding and related simplification of initializer expression EXPR. These behave identically to "fold_buildN" but igno= re potential run-time traps and exceptions that fold must preserve. */ int saved_signaling_nans =3D flag_signaling_nans;\ int saved_trapping_math =3D flag_trapping_math;\ int saved_rounding_math =3D flag_rounding_math;\ int saved_trapv =3D flag_trapv;\ int saved_folding_initializer =3D folding_initializer;\ flag_signaling_nans =3D 0;\ flag_trapping_math =3D 0;\ flag_rounding_math =3D 0;\ flag_trapv =3D 0;\ folding_initializer =3D 1; flag_signaling_nans =3D saved_signaling_nans;\ flag_trapping_math =3D saved_trapping_math;\ flag_rounding_math =3D saved_rounding_math;\ flag_trapv =3D saved_trapv;\ folding_initializer =3D saved_folding_initializer; So, shall cxx_eval_outermost_constant_expr instead turn off all those options (then warning_sentinel wouldn't be the right thing to use, but given the 8 or how many return stmts in cxx_eval_outermost_constant_expr, we'd need a RAII class for this. Not sure about the folding_initializer, th= at one is affecting complex multiplication and division constant evaluation somehow. 2020-09-03 Jakub Jelinek PR c++/96862 * constexpr.c (cxx_eval_outermost_constant_expr): Temporarily disable flag_rounding_math during manifestly constant evaluation. * g++.dg/cpp1z/constexpr-96862.C: New test. (cherry picked from commit 6641d6d3fe79113f8d9f3ced355aea79bffda822)=