public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/27524] New: -fbounds-check interracts *strangely* with an array of size 1
@ 2006-05-09 19:10 P dot Schaffnit at access dot rwth-aachen dot de
2006-05-10 11:34 ` [Bug fortran/27524] " P dot Schaffnit at access dot rwth-aachen dot de
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: P dot Schaffnit at access dot rwth-aachen dot de @ 2006-05-09 19:10 UTC (permalink / raw)
To: gcc-bugs
Hi!
I've spotted something quite strange with -fbounds-check and an array which
happens to have a size of 1 (a quite unlikely configuration admitedly, but
could be the tip of s(omething worse, worth investigating I guess).
I was able to reproduce this behaviour with a small variation on Paul Thomas's
example for PR 27124 (is it related to that in any way?)): if the size of the
array is 1 *and* -fbounds-check is specified it returns some junk (1075191960
for me), and otherwise (I mean, another size of the array and/or without
-fbounds-check) it returns the expected 10.
Philippe
PS: a small example exhibiting this behaviour:
PROGRAM Test
IMPLICIT NONE
INTEGER, PARAMETER :: Array_Size = 1
INTEGER :: Array(Array_Size)
Array = 100
Array = Function_Test ( Array, 10 )
WRITE ( 6, * ) Array
CONTAINS
FUNCTION Function_Test ( Array, Scalar )
INTEGER, INTENT(IN) :: Array(1:Array_Size), Scalar
INTEGER :: Function_Test(1:Array_Size)
Function_Test = Array / Scalar
END FUNCTION Function_Test
END PROGRAM Test
PPS: how I start it: gfortran -g -fbounds-check Test.f90 -o Test ; ./Test
PPPS: I'm using reasonably up-to-date sources:
gfortran --v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /USER/philippe/Irix/Gcc_Sources/configure
--prefix=/usr1/MICRESS/Philippe/Tools/Gcc --enable-languages=c,fortran
--disable-maintainer-mode --disable-shared
--with-mpfr=usr1/MICRESS/Philippe/Tools/Mpfr
--with-gmp=/usr1/MICRESS/Philippe/Tools/Gmp
Thread model: posix
gcc version 4.2.0 20060508 (experimental)
--
Summary: -fbounds-check interracts *strangely* with an array of
size 1
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: P dot Schaffnit at access dot rwth-aachen dot de
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27524
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/27524] -fbounds-check interracts *strangely* with an array of size 1
2006-05-09 19:10 [Bug fortran/27524] New: -fbounds-check interracts *strangely* with an array of size 1 P dot Schaffnit at access dot rwth-aachen dot de
@ 2006-05-10 11:34 ` P dot Schaffnit at access dot rwth-aachen dot de
2006-05-19 16:59 ` [Bug libfortran/27524] " fxcoudert at gcc dot gnu dot org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: P dot Schaffnit at access dot rwth-aachen dot de @ 2006-05-10 11:34 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from P dot Schaffnit at access dot rwth-aachen dot de 2006-05-10 11:34 -------
Sorry, I missed it before, but this could definitly be a dupplicate of 19777.
Philippe
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27524
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libfortran/27524] -fbounds-check interracts *strangely* with an array of size 1
2006-05-09 19:10 [Bug fortran/27524] New: -fbounds-check interracts *strangely* with an array of size 1 P dot Schaffnit at access dot rwth-aachen dot de
2006-05-10 11:34 ` [Bug fortran/27524] " P dot Schaffnit at access dot rwth-aachen dot de
@ 2006-05-19 16:59 ` fxcoudert at gcc dot gnu dot org
2006-05-24 9:21 ` fxcoudert at gcc dot gnu dot org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-05-19 16:59 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from fxcoudert at gcc dot gnu dot org 2006-05-19 16:59 -------
Not sure if it's a duplicate. Here's a reduced testcase, anyhow:
print *, F()
contains
function F()
integer :: F(1)
f = 1
end function F
end
$ gfortran -v
Using built-in specs.
Target: i386-linux
Configured with: ../gcc/configure --prefix=/tmp/gfortran-20060519/irun
--enable-languages=c,fortran --host=i386-linux
--with-gmp=/tmp/gfortran-20060519/gfortran_libs
Thread model: posix
gcc version 4.2.0 20060519 (experimental)
$ gfortran bounds.f90 && ./a.out
1
$ gfortran bounds.f90 -fbounds-check && ./a.out
5090100
zsh: bus error ./a.out
--
fxcoudert at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |fxcoudert at gcc dot gnu dot
| |org
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2006-05-19 16:59:16
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27524
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libfortran/27524] -fbounds-check interracts *strangely* with an array of size 1
2006-05-09 19:10 [Bug fortran/27524] New: -fbounds-check interracts *strangely* with an array of size 1 P dot Schaffnit at access dot rwth-aachen dot de
2006-05-10 11:34 ` [Bug fortran/27524] " P dot Schaffnit at access dot rwth-aachen dot de
2006-05-19 16:59 ` [Bug libfortran/27524] " fxcoudert at gcc dot gnu dot org
@ 2006-05-24 9:21 ` fxcoudert at gcc dot gnu dot org
2006-05-24 20:53 ` [Bug libfortran/27524] -fbounds-check interacts with array function fxcoudert at gcc dot gnu dot org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-05-24 9:21 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from fxcoudert at gcc dot gnu dot org 2006-05-24 09:20 -------
> function F()
> integer :: F(1)
> f = 1
> end function F
Compiling this simple function without and with -fbounds-check and dumping the
GIMPLE tree generated gives the following diff:
--- 003t.original.noboundscheck 2006-05-24 11:09:37.000000000 +0200
+++ 003t.original.boundscheck 2006-05-24 11:09:32.000000000 +0200
@@ -14,8 +14,16 @@ f (__result)
D.917 = __result->dim[0].stride;
stride.0 = D.917 == 0 ? 1 : D.917;
__result.0 = (int4[0:D.918] *) __result->data;
+ if ((logical4) __builtin_expect (__result->dim[0].ubound !=
__result->dim[0].lbound, 0))
+ {
+ _gfortran_runtime_error ("Array bound mismatch", "test.f90", 1);
+ }
+ else
+ {
+ (void) 0;
+ }
size.2 = NON_LVALUE_EXPR <stride.0>;
- offset.1 = -stride.0;
+ offset.1 = __result->dim[0].lbound - __result->dim[0].ubound;
D.918 = size.2 - 1;
D.919 = (bit_size_type) (<unnamed type>) size.2 *
I think the cuplrit here is gfc_trans_dummy_array_bias(), around line 3728
(where the offset is built), although I'm not skilled enough in all this to
understand how exactly to fix it.
--
fxcoudert at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed|2006-05-19 16:59:16 |2006-05-24 09:20:48
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27524
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libfortran/27524] -fbounds-check interacts with array function
2006-05-09 19:10 [Bug fortran/27524] New: -fbounds-check interracts *strangely* with an array of size 1 P dot Schaffnit at access dot rwth-aachen dot de
` (2 preceding siblings ...)
2006-05-24 9:21 ` fxcoudert at gcc dot gnu dot org
@ 2006-05-24 20:53 ` fxcoudert at gcc dot gnu dot org
2006-05-26 21:19 ` fxcoudert at gcc dot gnu dot org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-05-24 20:53 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from fxcoudert at gcc dot gnu dot org 2006-05-24 20:52 -------
(In reply to comment #3)
> I think the cuplrit here is gfc_trans_dummy_array_bias(), around line 3728
> (where the offset is built), although I'm not skilled enough in all this to
> understand how exactly to fix it.
OK, I think I made it. It's a typo, where the stride variable is used as a
temporary variable for creating a bounds-checking tree, but its value is needed
(and reused) later, leading to the bug.
Index: trans-array.c
===================================================================
--- trans-array.c (revision 113849)
+++ trans-array.c (working copy)
@@ -3564,7 +3564,7 @@
tree dumdesc;
tree tmp;
tree stmt;
- tree stride;
+ tree stride, stride2;
tree stmt_packed;
tree stmt_unpacked;
tree partial;
@@ -3711,9 +3711,9 @@
tmp = fold_build2 (MINUS_EXPR, gfc_array_index_type,
ubound, lbound);
- stride = build2 (MINUS_EXPR, gfc_array_index_type,
+ stride2 = build2 (MINUS_EXPR, gfc_array_index_type,
dubound, dlbound);
- tmp = fold_build2 (NE_EXPR, gfc_array_index_type, tmp, stride);
+ tmp = fold_build2 (NE_EXPR, gfc_array_index_type, tmp, stride2);
gfc_trans_runtime_check (tmp, gfc_strconst_bounds, &block);
}
}
--
fxcoudert at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |fxcoudert at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
Last reconfirmed|2006-05-24 09:20:48 |2006-05-24 20:52:53
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27524
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libfortran/27524] -fbounds-check interacts with array function
2006-05-09 19:10 [Bug fortran/27524] New: -fbounds-check interracts *strangely* with an array of size 1 P dot Schaffnit at access dot rwth-aachen dot de
` (3 preceding siblings ...)
2006-05-24 20:53 ` [Bug libfortran/27524] -fbounds-check interacts with array function fxcoudert at gcc dot gnu dot org
@ 2006-05-26 21:19 ` fxcoudert at gcc dot gnu dot org
2006-05-26 21:20 ` [Bug libfortran/27524] [4.1 only] " fxcoudert at gcc dot gnu dot org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-05-26 21:19 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from fxcoudert at gcc dot gnu dot org 2006-05-26 21:18 -------
Subject: Bug 27524
Author: fxcoudert
Date: Fri May 26 21:18:45 2006
New Revision: 114142
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114142
Log:
PR fortran/27524
* trans-array.c (gfc_trans_dummy_array_bias): Don't use stride as
a temporary variable when -fbounds-check is enabled, since its
value will be needed later.
* gfortran.dg/bounds_check_1.f90: New test.
Added:
trunk/gcc/testsuite/gfortran.dg/bounds_check_1.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/trans-array.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27524
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libfortran/27524] [4.1 only] -fbounds-check interacts with array function
2006-05-09 19:10 [Bug fortran/27524] New: -fbounds-check interracts *strangely* with an array of size 1 P dot Schaffnit at access dot rwth-aachen dot de
` (4 preceding siblings ...)
2006-05-26 21:19 ` fxcoudert at gcc dot gnu dot org
@ 2006-05-26 21:20 ` fxcoudert at gcc dot gnu dot org
2006-05-27 8:30 ` fxcoudert at gcc dot gnu dot org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-05-26 21:20 UTC (permalink / raw)
To: gcc-bugs
--
fxcoudert at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to fail| |4.1.2
Known to work| |4.2.0
Summary|-fbounds-check interacts |[4.1 only] -fbounds-check
|with array function |interacts with array
| |function
Target Milestone|--- |4.1.2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27524
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libfortran/27524] [4.1 only] -fbounds-check interacts with array function
2006-05-09 19:10 [Bug fortran/27524] New: -fbounds-check interracts *strangely* with an array of size 1 P dot Schaffnit at access dot rwth-aachen dot de
` (5 preceding siblings ...)
2006-05-26 21:20 ` [Bug libfortran/27524] [4.1 only] " fxcoudert at gcc dot gnu dot org
@ 2006-05-27 8:30 ` fxcoudert at gcc dot gnu dot org
2006-06-03 16:07 ` fxcoudert at gcc dot gnu dot org
2006-06-03 16:08 ` [Bug libfortran/27524] " fxcoudert at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-05-27 8:30 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from fxcoudert at gcc dot gnu dot org 2006-05-27 08:29 -------
*** Bug 27760 has been marked as a duplicate of this bug. ***
--
fxcoudert at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |vivekrao4 at yahoo dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27524
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libfortran/27524] [4.1 only] -fbounds-check interacts with array function
2006-05-09 19:10 [Bug fortran/27524] New: -fbounds-check interracts *strangely* with an array of size 1 P dot Schaffnit at access dot rwth-aachen dot de
` (6 preceding siblings ...)
2006-05-27 8:30 ` fxcoudert at gcc dot gnu dot org
@ 2006-06-03 16:07 ` fxcoudert at gcc dot gnu dot org
2006-06-03 16:08 ` [Bug libfortran/27524] " fxcoudert at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-06-03 16:07 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from fxcoudert at gcc dot gnu dot org 2006-06-03 16:07 -------
Subject: Bug 27524
Author: fxcoudert
Date: Sat Jun 3 16:06:51 2006
New Revision: 114342
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114342
Log:
PR fortran/19777
* trans-array.c (gfc_conv_array_ref): Don't perform out-of-bounds
checking for assumed-size arrrays.
* gfortran.dg/bounds_check_2.f: New test.
PR fortran/27524
* trans-array.c (gfc_trans_dummy_array_bias): Don't use stride as
a temporary variable when -fbounds-check is enabled, since its
value will be needed later.
* gfortran.dg/bounds_check_1.f90: New test.
Added:
branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/bounds_check_1.f90
- copied unchanged from r114142,
trunk/gcc/testsuite/gfortran.dg/bounds_check_1.f90
branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/bounds_check_2.f
- copied unchanged from r114153,
trunk/gcc/testsuite/gfortran.dg/bounds_check_2.f
Modified:
branches/gcc-4_1-branch/gcc/fortran/ChangeLog
branches/gcc-4_1-branch/gcc/fortran/trans-array.c
branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27524
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libfortran/27524] -fbounds-check interacts with array function
2006-05-09 19:10 [Bug fortran/27524] New: -fbounds-check interracts *strangely* with an array of size 1 P dot Schaffnit at access dot rwth-aachen dot de
` (7 preceding siblings ...)
2006-06-03 16:07 ` fxcoudert at gcc dot gnu dot org
@ 2006-06-03 16:08 ` fxcoudert at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-06-03 16:08 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from fxcoudert at gcc dot gnu dot org 2006-06-03 16:07 -------
Fixed.
--
fxcoudert at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Known to fail|4.1.2 |
Known to work|4.2.0 |4.2.0 4.1.2
Resolution| |FIXED
Summary|[4.1 only] -fbounds-check |-fbounds-check interacts
|interacts with array |with array function
|function |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27524
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2006-06-03 16:08 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-09 19:10 [Bug fortran/27524] New: -fbounds-check interracts *strangely* with an array of size 1 P dot Schaffnit at access dot rwth-aachen dot de
2006-05-10 11:34 ` [Bug fortran/27524] " P dot Schaffnit at access dot rwth-aachen dot de
2006-05-19 16:59 ` [Bug libfortran/27524] " fxcoudert at gcc dot gnu dot org
2006-05-24 9:21 ` fxcoudert at gcc dot gnu dot org
2006-05-24 20:53 ` [Bug libfortran/27524] -fbounds-check interacts with array function fxcoudert at gcc dot gnu dot org
2006-05-26 21:19 ` fxcoudert at gcc dot gnu dot org
2006-05-26 21:20 ` [Bug libfortran/27524] [4.1 only] " fxcoudert at gcc dot gnu dot org
2006-05-27 8:30 ` fxcoudert at gcc dot gnu dot org
2006-06-03 16:07 ` fxcoudert at gcc dot gnu dot org
2006-06-03 16:08 ` [Bug libfortran/27524] " fxcoudert at gcc dot gnu dot 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).