From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by sourceware.org (Postfix) with ESMTPS id 5F6273858426; Fri, 6 Oct 2023 20:38:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5F6273858426 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1696624686; x=1697229486; i=anlauf@gmx.de; bh=SJm/3WCtHi4VA57ONx9E9OYQd34GIs/lXnQpuPNh8vI=; h=X-UI-Sender-Class:From:To:Subject:Date; b=bTJqp/2uL2Tn84KNBdN5GXyagFs+y7rshmdRLyTxgygXM0a08wOoaRrH2HdYBSw5VoRrzNA4eGS bg7kjBB5l5xOmy4+NCjSM5jogbcdktfJpGP/uO8PuZkiLk/UVmT4j/dNTt5KUOqGyjy10ClFBKcEf At8jgB6f+n+WwF+aIhghXsZehl/aBq/TTtZgFDMMFKKloSV0FODUKEx5NlWrk3mVPDL1aUiCbouKD iXoh1cxf+TOXC9IRv4mUVTO7cPJocfnPlwVFrr17tKCHMJXr0k8HbHR65wSdnXdiQyByOPtCwnhm0 ySxpGQGBHGQSJveylLO9YVv+gldMKmPyfV7A== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [79.232.147.245] ([79.232.147.245]) by web-mail.gmx.net (3c-app-gmx-bap40.server.lan [172.19.172.110]) (via HTTP); Fri, 6 Oct 2023 22:38:06 +0200 MIME-Version: 1.0 Message-ID: From: Harald Anlauf To: fortran , gcc-patches Subject: [PATCH] fortran: fix handling of options -ffpe-trap and -ffpe-summary [PR110957] Content-Type: multipart/mixed; boundary=rekceb-cac33b39-86c7-46aa-a516-db9f83c5c06b Date: Fri, 6 Oct 2023 22:38:06 +0200 Importance: normal Sensitivity: Normal X-Priority: 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S56Gk1E2C0S+xyTdM/1YqS3YqZoCgvvH4eevxNqIYbAitU Vbt0aX+m25RkeCY9y1K1m747X2UAL8P8BUS8XHDW2e5lctwdMiSfp0116qsFsovax7uohZhF6 nXcKjQScPba5I/dF4d8esQTZ9BmoX3V7GT2kdx37uYF5k= X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_BARRACUDACENTRAL,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --rekceb-cac33b39-86c7-46aa-a516-db9f83c5c06b Content-Type: text/plain; charset=UTF-8 Dear all, the attached simple patch fixes a mixup of error messages for -ffpe-trap and -ffpe-summary. While at it, I though it might be useful to accept 'none' as allowable argument to -ffpe-trap, so that traps previously set on the command line may be cleared. This change is also documented. Regtested on x86_64-pc-linux-gnu. OK for mainline? *** The reporter also suggested to detect and handle -fno-trapping-math when any trap is enabled. I am not so sure that this can be required. In gfortran, specifying -ffpe-trap sets the FPU mask in the main and has no further effect. Or am I missing something? Any further opinions or insights? Thanks, Harald --rekceb-cac33b39-86c7-46aa-a516-db9f83c5c06b Content-Type: text/x-patch Content-Disposition: attachment; filename=pr110957.diff Content-Transfer-Encoding: quoted-printable =46rom 75dc455f21cea07e64b422c9994ab8879df388de Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Fri, 6 Oct 2023 22:21:56 +0200 Subject: [PATCH] fortran: fix handling of options -ffpe-trap and -ffpe-sum= mary [PR110957] gcc/fortran/ChangeLog: PR fortran/110957 * invoke.texi: Update documentation to reflect '-ffpe-trap=3Dnone'. * options.cc (gfc_handle_fpe_option): Fix mixup up of error messages for options -ffpe-trap and -ffpe-summary. Accept '-ffpe-trap=3Dnone' to clear FPU traps previously set on command line. =2D-- gcc/fortran/invoke.texi | 6 ++++-- gcc/fortran/options.cc | 9 ++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/gcc/fortran/invoke.texi b/gcc/fortran/invoke.texi index 38150b1e29e..10387e39501 100644 =2D-- a/gcc/fortran/invoke.texi +++ b/gcc/fortran/invoke.texi @@ -1294,7 +1294,8 @@ Specify a list of floating point exception traps to = enable. On most systems, if a floating point exception occurs and the trap for that exception is enabled, a SIGFPE signal will be sent and the program being aborted, producing a core file useful for debugging. @var{list} -is a (possibly empty) comma-separated list of the following +is a (possibly empty) comma-separated list of either @samp{none} (to +clear the set of exceptions to be trapped), or of the following exceptions: @samp{invalid} (invalid floating point operation, such as @code{SQRT(-1.0)}), @samp{zero} (division by zero), @samp{overflow} (overflow in a floating point operation), @samp{underflow} (underflow @@ -1314,7 +1315,8 @@ If the option is used more than once in the command = line, the lists will be joined: '@code{ffpe-trap=3D}@var{list1} @code{ffpe-trap=3D}@var{list2}= ' is equivalent to @code{ffpe-trap=3D}@var{list1},@var{list2}. -Note that once enabled an exception cannot be disabled (no negative form)= . +Note that once enabled an exception cannot be disabled (no negative form)= , +except by clearing all traps by specifying @samp{none}. Many, if not most, floating point operations incur loss of precision due to rounding, and hence the @code{ffpe-trap=3Dinexact} is likely to diff --git a/gcc/fortran/options.cc b/gcc/fortran/options.cc index 27311961325..2ad22478042 100644 =2D-- a/gcc/fortran/options.cc +++ b/gcc/fortran/options.cc @@ -555,9 +555,12 @@ gfc_handle_fpe_option (const char *arg, bool trap) pos++; result =3D 0; - if (!trap && strncmp ("none", arg, pos) =3D=3D 0) + if (strncmp ("none", arg, pos) =3D=3D 0) { - gfc_option.fpe_summary =3D 0; + if (trap) + gfc_option.fpe =3D 0; + else + gfc_option.fpe_summary =3D 0; arg +=3D pos; pos =3D 0; continue; @@ -586,7 +589,7 @@ gfc_handle_fpe_option (const char *arg, bool trap) break; } } - if (!result && !trap) + if (!result && trap) gfc_fatal_error ("Argument to %<-ffpe-trap%> is not valid: %s", arg); else if (!result) gfc_fatal_error ("Argument to %<-ffpe-summary%> is not valid: %s", arg); =2D- 2.35.3 --rekceb-cac33b39-86c7-46aa-a516-db9f83c5c06b--