public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/109511] New: incorrectly rejects set_exponent with constant negative exponent
@ 2023-04-14 9:52 sebastien at debian dot org
2023-04-14 11:54 ` [Bug fortran/109511] " anlauf at gcc dot gnu.org
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: sebastien at debian dot org @ 2023-04-14 9:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109511
Bug ID: 109511
Summary: incorrectly rejects set_exponent with constant
negative exponent
Product: gcc
Version: 12.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: sebastien at debian dot org
Target Milestone: ---
The following program fails to compile:
program exponent
print *, set_exponent(1., -1)
end program exponent
With the following error message:
exponent.f08:2:24:
2 | print *, set_exponent(1., -1)
| 1
Error: Result of SET_EXPONENT overflows its kind at (1)
But as I understand it, this is a valid program.
Note that the problem does not occur if the exponent is positive. It also does
not occur if the exponent is variable (even with a negative value). So it looks
like the static analyzer is overly restrictive.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/109511] incorrectly rejects set_exponent with constant negative exponent
2023-04-14 9:52 [Bug fortran/109511] New: incorrectly rejects set_exponent with constant negative exponent sebastien at debian dot org
@ 2023-04-14 11:54 ` anlauf at gcc dot gnu.org
2023-04-14 17:19 ` anlauf at gcc dot gnu.org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-04-14 11:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109511
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Keywords| |wrong-code
CC| |anlauf at gcc dot gnu.org
Ever confirmed|0 |1
Last reconfirmed| |2023-04-14
--- Comment #1 from anlauf at gcc dot gnu.org ---
Confirmed.
The simplification seems to use the old mpfr_mul_2exp which takes an
unsigned exponent. There is the newer mpfr_mul_2si which accepts a signed
exponent.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/109511] incorrectly rejects set_exponent with constant negative exponent
2023-04-14 9:52 [Bug fortran/109511] New: incorrectly rejects set_exponent with constant negative exponent sebastien at debian dot org
2023-04-14 11:54 ` [Bug fortran/109511] " anlauf at gcc dot gnu.org
@ 2023-04-14 17:19 ` anlauf at gcc dot gnu.org
2023-04-14 17:36 ` anlauf at gcc dot gnu.org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-04-14 17:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109511
--- Comment #2 from anlauf at gcc dot gnu.org ---
It's even worse, as simplification for arguments X below one gives wrong
results:
set_exponent(0.75, 3)
gives 3.00000000, while the runtime version correctly prints 6.000000
All gfortran versions seem to be affected.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/109511] incorrectly rejects set_exponent with constant negative exponent
2023-04-14 9:52 [Bug fortran/109511] New: incorrectly rejects set_exponent with constant negative exponent sebastien at debian dot org
2023-04-14 11:54 ` [Bug fortran/109511] " anlauf at gcc dot gnu.org
2023-04-14 17:19 ` anlauf at gcc dot gnu.org
@ 2023-04-14 17:36 ` anlauf at gcc dot gnu.org
2023-04-14 19:01 ` anlauf at gcc dot gnu.org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-04-14 17:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109511
--- Comment #3 from anlauf at gcc dot gnu.org ---
Created attachment 54860
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54860&action=edit
Patch
Patch I am testing.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/109511] incorrectly rejects set_exponent with constant negative exponent
2023-04-14 9:52 [Bug fortran/109511] New: incorrectly rejects set_exponent with constant negative exponent sebastien at debian dot org
` (2 preceding siblings ...)
2023-04-14 17:36 ` anlauf at gcc dot gnu.org
@ 2023-04-14 19:01 ` anlauf at gcc dot gnu.org
2023-04-14 19:23 ` sebastien at debian dot org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-04-14 19:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109511
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |anlauf at gcc dot gnu.org
Status|NEW |ASSIGNED
--- Comment #4 from anlauf at gcc dot gnu.org ---
Submitted, with an additional fix for negative X:
https://gcc.gnu.org/pipermail/fortran/2023-April/059182.html
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/109511] incorrectly rejects set_exponent with constant negative exponent
2023-04-14 9:52 [Bug fortran/109511] New: incorrectly rejects set_exponent with constant negative exponent sebastien at debian dot org
` (3 preceding siblings ...)
2023-04-14 19:01 ` anlauf at gcc dot gnu.org
@ 2023-04-14 19:23 ` sebastien at debian dot org
2023-04-14 19:51 ` cvs-commit at gcc dot gnu.org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: sebastien at debian dot org @ 2023-04-14 19:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109511
--- Comment #5 from Sébastien Villemot <sebastien at debian dot org> ---
Thanks for your work on this issue!
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/109511] incorrectly rejects set_exponent with constant negative exponent
2023-04-14 9:52 [Bug fortran/109511] New: incorrectly rejects set_exponent with constant negative exponent sebastien at debian dot org
` (4 preceding siblings ...)
2023-04-14 19:23 ` sebastien at debian dot org
@ 2023-04-14 19:51 ` cvs-commit at gcc dot gnu.org
2023-04-15 13:44 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-04-14 19:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109511
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Harald Anlauf <anlauf@gcc.gnu.org>:
https://gcc.gnu.org/g:fa4cb42870df60deb8888dbd51e2ddc6d6ab9e6a
commit r13-7188-gfa4cb42870df60deb8888dbd51e2ddc6d6ab9e6a
Author: Harald Anlauf <anlauf@gmx.de>
Date: Fri Apr 14 20:45:19 2023 +0200
Fortran: fix compile-time simplification of SET_EXPONENT [PR109511]
gcc/fortran/ChangeLog:
PR fortran/109511
* simplify.cc (gfc_simplify_set_exponent): Fix implementation of
compile-time simplification of intrinsic SET_EXPONENT for argument
X < 1 and for I < 0.
gcc/testsuite/ChangeLog:
PR fortran/109511
* gfortran.dg/set_exponent_1.f90: New test.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/109511] incorrectly rejects set_exponent with constant negative exponent
2023-04-14 9:52 [Bug fortran/109511] New: incorrectly rejects set_exponent with constant negative exponent sebastien at debian dot org
` (5 preceding siblings ...)
2023-04-14 19:51 ` cvs-commit at gcc dot gnu.org
@ 2023-04-15 13:44 ` cvs-commit at gcc dot gnu.org
2023-04-16 18:52 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-04-15 13:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109511
--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:
https://gcc.gnu.org/g:64efeac03cb9fa2603bb6628712f3a2541aef1cb
commit r12-9402-g64efeac03cb9fa2603bb6628712f3a2541aef1cb
Author: Harald Anlauf <anlauf@gmx.de>
Date: Fri Apr 14 20:45:19 2023 +0200
Fortran: fix compile-time simplification of SET_EXPONENT [PR109511]
gcc/fortran/ChangeLog:
PR fortran/109511
* simplify.cc (gfc_simplify_set_exponent): Fix implementation of
compile-time simplification of intrinsic SET_EXPONENT for argument
X < 1 and for I < 0.
gcc/testsuite/ChangeLog:
PR fortran/109511
* gfortran.dg/set_exponent_1.f90: New test.
(cherry picked from commit fa4cb42870df60deb8888dbd51e2ddc6d6ab9e6a)
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/109511] incorrectly rejects set_exponent with constant negative exponent
2023-04-14 9:52 [Bug fortran/109511] New: incorrectly rejects set_exponent with constant negative exponent sebastien at debian dot org
` (6 preceding siblings ...)
2023-04-15 13:44 ` cvs-commit at gcc dot gnu.org
@ 2023-04-16 18:52 ` cvs-commit at gcc dot gnu.org
2023-04-16 19:01 ` cvs-commit at gcc dot gnu.org
2023-04-16 19:02 ` anlauf at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-04-16 18:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109511
--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:
https://gcc.gnu.org/g:dfcdb457c462b9e35eb54d3b758221a119067e24
commit r11-10625-gdfcdb457c462b9e35eb54d3b758221a119067e24
Author: Harald Anlauf <anlauf@gmx.de>
Date: Fri Apr 14 20:45:19 2023 +0200
Fortran: fix compile-time simplification of SET_EXPONENT [PR109511]
gcc/fortran/ChangeLog:
PR fortran/109511
* simplify.c (gfc_simplify_set_exponent): Fix implementation of
compile-time simplification of intrinsic SET_EXPONENT for argument
X < 1 and for I < 0.
gcc/testsuite/ChangeLog:
PR fortran/109511
* gfortran.dg/set_exponent_1.f90: New test.
(cherry picked from commit fa4cb42870df60deb8888dbd51e2ddc6d6ab9e6a)
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/109511] incorrectly rejects set_exponent with constant negative exponent
2023-04-14 9:52 [Bug fortran/109511] New: incorrectly rejects set_exponent with constant negative exponent sebastien at debian dot org
` (7 preceding siblings ...)
2023-04-16 18:52 ` cvs-commit at gcc dot gnu.org
@ 2023-04-16 19:01 ` cvs-commit at gcc dot gnu.org
2023-04-16 19:02 ` anlauf at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-04-16 19:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109511
--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:
https://gcc.gnu.org/g:dd2cd1e70509aaeb3db3e7b322d8357bac817632
commit r10-11289-gdd2cd1e70509aaeb3db3e7b322d8357bac817632
Author: Harald Anlauf <anlauf@gmx.de>
Date: Fri Apr 14 20:45:19 2023 +0200
Fortran: fix compile-time simplification of SET_EXPONENT [PR109511]
gcc/fortran/ChangeLog:
PR fortran/109511
* simplify.c (gfc_simplify_set_exponent): Fix implementation of
compile-time simplification of intrinsic SET_EXPONENT for argument
X < 1 and for I < 0.
gcc/testsuite/ChangeLog:
PR fortran/109511
* gfortran.dg/set_exponent_1.f90: New test.
(cherry picked from commit fa4cb42870df60deb8888dbd51e2ddc6d6ab9e6a)
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/109511] incorrectly rejects set_exponent with constant negative exponent
2023-04-14 9:52 [Bug fortran/109511] New: incorrectly rejects set_exponent with constant negative exponent sebastien at debian dot org
` (8 preceding siblings ...)
2023-04-16 19:01 ` cvs-commit at gcc dot gnu.org
@ 2023-04-16 19:02 ` anlauf at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-04-16 19:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109511
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Target Milestone|--- |10.5
Resolution|--- |FIXED
--- Comment #10 from anlauf at gcc dot gnu.org ---
Fixed on mainline for gcc-13, and on all open branches. Closing.
Thanks for the report!
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2023-04-16 19:02 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-14 9:52 [Bug fortran/109511] New: incorrectly rejects set_exponent with constant negative exponent sebastien at debian dot org
2023-04-14 11:54 ` [Bug fortran/109511] " anlauf at gcc dot gnu.org
2023-04-14 17:19 ` anlauf at gcc dot gnu.org
2023-04-14 17:36 ` anlauf at gcc dot gnu.org
2023-04-14 19:01 ` anlauf at gcc dot gnu.org
2023-04-14 19:23 ` sebastien at debian dot org
2023-04-14 19:51 ` cvs-commit at gcc dot gnu.org
2023-04-15 13:44 ` cvs-commit at gcc dot gnu.org
2023-04-16 18:52 ` cvs-commit at gcc dot gnu.org
2023-04-16 19:01 ` cvs-commit at gcc dot gnu.org
2023-04-16 19:02 ` anlauf at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).