public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/50790] New: ICE in copy_constant on divide by expression that evaluates to zero
@ 2011-10-19 11:41 jonathan.hogg at stfc dot ac.uk
2011-10-19 15:24 ` [Bug middle-end/50790] " burnus at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: jonathan.hogg at stfc dot ac.uk @ 2011-10-19 11:41 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50790
Bug #: 50790
Summary: ICE in copy_constant on divide by expression that
evaluates to zero
Classification: Unclassified
Product: gcc
Version: 4.6.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: jonathan.hogg@stfc.ac.uk
The following code produces an ICE for me:
program test
implicit none
integer :: i
i = 3
print *, "chk", 3/(i-i)
end program test
This should presumably produce
Error: Division by zero
at compile time (or run time if we're not being clever).
Produced with:
GNU Fortran (Debian 4.6.1-4) 4.6.1
Copyright (C) 2011 Free Software Foundation, Inc.
Thanks,
Jonathan.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug middle-end/50790] ICE in copy_constant on divide by expression that evaluates to zero
2011-10-19 11:41 [Bug fortran/50790] New: ICE in copy_constant on divide by expression that evaluates to zero jonathan.hogg at stfc dot ac.uk
@ 2011-10-19 15:24 ` burnus at gcc dot gnu.org
2011-10-19 17:55 ` kargl at gcc dot gnu.org
2021-12-19 4:17 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-10-19 15:24 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50790
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |burnus at gcc dot gnu.org
Component|fortran |middle-end
--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-10-19 15:23:55 UTC ---
-fdump-tree-original:
static integer(kind=4) C.1534 = 3 / 0;
_gfortran_transfer_integer_write (&dt_parm.0, &C.1534, 4);
It gives with 4.7 the ICE:
internal compiler error: in copy_constant, at varasm.c:3031
I think it is - at least in general - not be detectable in the front end but
only in the ME.
A similar C test case works (cf. below for a simpler version); I think there is
no compiler option to print a warning -- at least -Wall -Wextra don't.
int
main ()
{
int i = 3;
printf ("%d\n", 3/(i-i));
return 0;
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug middle-end/50790] ICE in copy_constant on divide by expression that evaluates to zero
2011-10-19 11:41 [Bug fortran/50790] New: ICE in copy_constant on divide by expression that evaluates to zero jonathan.hogg at stfc dot ac.uk
2011-10-19 15:24 ` [Bug middle-end/50790] " burnus at gcc dot gnu.org
@ 2011-10-19 17:55 ` kargl at gcc dot gnu.org
2021-12-19 4:17 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: kargl at gcc dot gnu.org @ 2011-10-19 17:55 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50790
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kargl at gcc dot gnu.org
--- Comment #2 from kargl at gcc dot gnu.org 2011-10-19 17:54:31 UTC ---
Here's a variation on the original code, which removes
the print statement. One does not need to wade through
gfortran IO structure.
program test
implicit none
integer i
i = 3
call foo (3 / (i - i))
end program test
subroutine foo(j)
j = j * 1
end subroutine foo
The dump shows
foo (integer(kind=4) & restrict j)
{
*j = NON_LVALUE_EXPR <*j>;
}
test ()
{
integer(kind=4) i;
i = 3;
{
static integer(kind=4) C.1729 = 3 / 0;
foo (&C.1729);
}
}
An equivalent C program compiles and gives a nearly identical
dump, but dies with a Floating exception(?)
troutmask:sgk[247] cat dw.c
void
foo (int *j)
{
*j = *j * 2;
}
int
main()
{
static int i = 3;
i = 3 / (i - i);
foo(&i);
return 0;
}
troutmask:sgk[248] ~/work/4x/bin/gcc -o z dw.c && ./z
Floating exception (core dumped)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug middle-end/50790] ICE in copy_constant on divide by expression that evaluates to zero
2011-10-19 11:41 [Bug fortran/50790] New: ICE in copy_constant on divide by expression that evaluates to zero jonathan.hogg at stfc dot ac.uk
2011-10-19 15:24 ` [Bug middle-end/50790] " burnus at gcc dot gnu.org
2011-10-19 17:55 ` kargl at gcc dot gnu.org
@ 2021-12-19 4:17 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-19 4:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50790
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Target Milestone|--- |8.0
Known to work| |8.1.0
Known to fail| |4.9.4, 5.5.0, 6.3.0, 7.1.0,
| |7.2.0, 7.3.0
Status|WAITING |RESOLVED
Keywords| |ice-on-valid-code
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-12-19 4:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-19 11:41 [Bug fortran/50790] New: ICE in copy_constant on divide by expression that evaluates to zero jonathan.hogg at stfc dot ac.uk
2011-10-19 15:24 ` [Bug middle-end/50790] " burnus at gcc dot gnu.org
2011-10-19 17:55 ` kargl at gcc dot gnu.org
2021-12-19 4:17 ` pinskia 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).