* [Bug fortran/31538] result_in_spec_1.f90: Invalid write
2007-04-11 15:08 [Bug fortran/31538] New: result_in_spec_1.f90: Invalid write burnus at gcc dot gnu dot org
@ 2007-04-11 19:26 ` burnus at gcc dot gnu dot org
2007-04-11 20:05 ` paulthomas2 at wanadoo dot fr
` (11 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-04-11 19:26 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from burnus at gcc dot gnu dot org 2007-04-11 20:26 -------
Actually, it turned out that this is an out-of-bounds problem:
character(len(ch)) :: chr(2)
chr = test2 (1)
however, test(1) returns an array of the size (2*1+1)+1 = 4.
gfortran's -fbounds-check message is a bit misleading, though:
Fortran runtime error: Array bound mismatch for dimension 1 of array 'r' (in
file '/home/tob/projects/gcc/gcc/testsuite/gfortran.dg/result_in_spec_1.f90',
at line 22)
I think NAG f95's is better:
Rank 1 of array operand has extent 4 instead of 2
In MYFUNC, line 42 of result_in_spec_1.f90
Line 22 is:
do i = 1, len(r)
where "r" is function result character(len=3),dimension(4). And line 42 is:
chr = test2 (1)
The test case needs to be fixed, the question is whether the bounding error
should be improved too?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31538
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/31538] result_in_spec_1.f90: Invalid write
2007-04-11 15:08 [Bug fortran/31538] New: result_in_spec_1.f90: Invalid write burnus at gcc dot gnu dot org
2007-04-11 19:26 ` [Bug fortran/31538] " burnus at gcc dot gnu dot org
@ 2007-04-11 20:05 ` paulthomas2 at wanadoo dot fr
2007-04-11 21:48 ` pault at gcc dot gnu dot org
` (10 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: paulthomas2 at wanadoo dot fr @ 2007-04-11 20:05 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from paulthomas2 at wanadoo dot fr 2007-04-11 21:05 -------
Subject: Re: result_in_spec_1.f90: Invalid write
Tobias,
> however, test(1) returns an array of the size (2*1+1)+1 = 4.
>
Thanks for spotting that one. I'm just in the process of committing the
fix as 'obvious', if a very sluggish network will permit.
> gfortran's -fbounds-check message is a bit misleading, though:
>
> Fortran runtime error: Array bound mismatch for dimension 1 of array 'r' (in
> file '/home/tob/projects/gcc/gcc/testsuite/gfortran.dg/result_in_spec_1.f90',
> at line 22)
>
> I think NAG f95's is better:
>
> Rank 1 of array operand has extent 4 instead of 2
> In MYFUNC, line 42 of result_in_spec_1.f90
>
> Line 22 is:
> do i = 1, len(r)
> where "r" is function result character(len=3),dimension(4). And line 42 is:
> chr = test2 (1)
>
> The test case needs to be fixed, the question is whether the bounding error
> should be improved too?
>
Yes, the line number should certainly be put right.
Cheers
Paul
>
>
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31538
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/31538] result_in_spec_1.f90: Invalid write
2007-04-11 15:08 [Bug fortran/31538] New: result_in_spec_1.f90: Invalid write burnus at gcc dot gnu dot org
2007-04-11 19:26 ` [Bug fortran/31538] " burnus at gcc dot gnu dot org
2007-04-11 20:05 ` paulthomas2 at wanadoo dot fr
@ 2007-04-11 21:48 ` pault at gcc dot gnu dot org
2007-04-11 21:53 ` [Bug fortran/31538] misleading bounds check error pault at gcc dot gnu dot org
` (9 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-04-11 21:48 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from pault at gcc dot gnu dot org 2007-04-11 22:48 -------
Subject: Bug 31538
Author: pault
Date: Wed Apr 11 22:48:15 2007
New Revision: 123725
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123725
Log:
2007-04-11 Paul Thomas <pault@gcc.gnu.org>
PR testsuite/31538
* gfortran.dg/result_in_spec_1.f90: Increase dimension from 2
to 4 at line 38 to fix bounds problem.
Modified:
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gfortran.dg/result_in_spec_1.f90
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31538
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/31538] misleading bounds check error
2007-04-11 15:08 [Bug fortran/31538] New: result_in_spec_1.f90: Invalid write burnus at gcc dot gnu dot org
` (2 preceding siblings ...)
2007-04-11 21:48 ` pault at gcc dot gnu dot org
@ 2007-04-11 21:53 ` pault at gcc dot gnu dot org
2007-08-10 9:43 ` burnus at gcc dot gnu dot org
` (8 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-04-11 21:53 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from pault at gcc dot gnu dot org 2007-04-11 22:52 -------
I fixed the result_in_spec_1.f90 problem in trunk.
The diagnostic should remain as a problem, however. I have hijacked this PR
for it:)
Paul
--
pault at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords|wrong-code |diagnostic
Last reconfirmed|0000-00-00 00:00:00 |2007-04-11 22:52:54
date| |
Summary|result_in_spec_1.f90: |misleading bounds check
|Invalid write |error
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31538
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/31538] misleading bounds check error
2007-04-11 15:08 [Bug fortran/31538] New: result_in_spec_1.f90: Invalid write burnus at gcc dot gnu dot org
` (3 preceding siblings ...)
2007-04-11 21:53 ` [Bug fortran/31538] misleading bounds check error pault at gcc dot gnu dot org
@ 2007-08-10 9:43 ` burnus at gcc dot gnu dot org
2010-04-16 16:05 ` kargl at gcc dot gnu dot org
` (7 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-08-10 9:43 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from burnus at gcc dot gnu dot org 2007-08-10 09:43 -------
Newly created test case. Expected:
* Extend (size) should be printed for "a = f()", as NAG f95 does
(I'm not sure that "different shape" is correct for the current a=b message;
additionally, the A should not be capitalized and the D in different should.)
integer :: a(-4:1), b(0:4)
b = 5
! a(-4:1) = b(0:4) ! Error: different shape for Array
! ! assignment at (1) on dimension 1 (6/5)
!
! gfortran: Array bound mismatch for dimension 1 of array 'f'
! NAG f95: Rank 1 of array operand has extent 5 instead of 2
a(i:1) = f(b)
contains
function f(x)
integer :: x(:),f(size(x))
f = x
end function
end
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31538
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/31538] misleading bounds check error
2007-04-11 15:08 [Bug fortran/31538] New: result_in_spec_1.f90: Invalid write burnus at gcc dot gnu dot org
` (4 preceding siblings ...)
2007-08-10 9:43 ` burnus at gcc dot gnu dot org
@ 2010-04-16 16:05 ` kargl at gcc dot gnu dot org
2010-04-16 16:14 ` kargl at gcc dot gnu dot org
` (6 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: kargl at gcc dot gnu dot org @ 2010-04-16 16:05 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from kargl at gcc dot gnu dot org 2010-04-16 16:05 -------
(In reply to comment #5)
> Newly created test case. Expected:
> * Extend (size) should be printed for "a = f()", as NAG f95 does
>
> (I'm not sure that "different shape" is correct for the current a=b message;
> additionally, the A should not be capitalized and the D in different should.)
>
>
> integer :: a(-4:1), b(0:4)
> b = 5
> ! a(-4:1) = b(0:4) ! Error: different shape for Array
> ! ! assignment at (1) on dimension 1 (6/5)
> !
> ! gfortran: Array bound mismatch for dimension 1 of array 'f'
> ! NAG f95: Rank 1 of array operand has extent 5 instead of 2
> a(i:1) = f(b)
> contains
> function f(x)
> integer :: x(:),f(size(x))
> f = x
> end function
> end
>
The above is clearly invalid, so gfortran can go anything
it wants.
laptop:kargl[236] gfc4x -o z -fcheck=all g.f90 -Wuninitialized
g.f90: In function 'MAIN__':
g.f90:8:0: warning: 'i' may be used uninitialized in this function
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31538
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/31538] misleading bounds check error
2007-04-11 15:08 [Bug fortran/31538] New: result_in_spec_1.f90: Invalid write burnus at gcc dot gnu dot org
` (5 preceding siblings ...)
2010-04-16 16:05 ` kargl at gcc dot gnu dot org
@ 2010-04-16 16:14 ` kargl at gcc dot gnu dot org
2010-04-16 17:25 ` burnus at gcc dot gnu dot org
` (5 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: kargl at gcc dot gnu dot org @ 2010-04-16 16:14 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from kargl at gcc dot gnu dot org 2010-04-16 16:14 -------
(In reply to comment #6)
> (In reply to comment #5)
> > Newly created test case. Expected:
> > * Extend (size) should be printed for "a = f()", as NAG f95 does
> >
> > (I'm not sure that "different shape" is correct for the current a=b message;
> > additionally, the A should not be capitalized and the D in different should.)
> >
> >
> > integer :: a(-4:1), b(0:4)
> > b = 5
> > ! a(-4:1) = b(0:4) ! Error: different shape for Array
> > ! ! assignment at (1) on dimension 1 (6/5)
> > !
> > ! gfortran: Array bound mismatch for dimension 1 of array 'f'
> > ! NAG f95: Rank 1 of array operand has extent 5 instead of 2
> > a(i:1) = f(b)
> > contains
> > function f(x)
> > integer :: x(:),f(size(x))
> > f = x
> > end function
> > end
> >
>
> The above is clearly invalid, so gfortran can go anything
> it wants.
>
> laptop:kargl[236] gfc4x -o z -fcheck=all g.f90 -Wuninitialized
> g.f90: In function 'MAIN__':
> g.f90:8:0: warning: 'i' may be used uninitialized in this function
>
Assuming 'i = -4' is missing in the programming, why is the
runtime bounds check not a sufficient error message? IMHO,
I think this pr can be closed.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31538
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/31538] misleading bounds check error
2007-04-11 15:08 [Bug fortran/31538] New: result_in_spec_1.f90: Invalid write burnus at gcc dot gnu dot org
` (6 preceding siblings ...)
2010-04-16 16:14 ` kargl at gcc dot gnu dot org
@ 2010-04-16 17:25 ` burnus at gcc dot gnu dot org
2010-04-16 17:39 ` dominiq at lps dot ens dot fr
` (4 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-04-16 17:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from burnus at gcc dot gnu dot org 2010-04-16 17:24 -------
(In reply to comment #7)
> Assuming 'i = -4' is missing in the programming
Well, almost any number would do, but "i = -4" is fine.
> why is the runtime bounds check not a sufficient error message?
Because:
Fortran runtime error: Array bound mismatch for dimension 1 of array 'f'
is less helpful than our other gfortran out-of-bounds error messages; to be in
line with those, one should have:
Fortran runtime error: Array bound mismatch for dimension 1 of array 'f'
(5/2)
or something like that which should also the two extends. Knowing the extends
it can make it sometimes much easier to find the cause of the wrong extend.
In the comment of comment 5 you see how other gfortran errors look like
"(%d/%d)" and how the NAG error message looks like for this case ("extent 5
instead of 2").
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31538
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/31538] misleading bounds check error
2007-04-11 15:08 [Bug fortran/31538] New: result_in_spec_1.f90: Invalid write burnus at gcc dot gnu dot org
` (7 preceding siblings ...)
2010-04-16 17:25 ` burnus at gcc dot gnu dot org
@ 2010-04-16 17:39 ` dominiq at lps dot ens dot fr
2010-04-16 18:26 ` kargl at gcc dot gnu dot org
` (3 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: dominiq at lps dot ens dot fr @ 2010-04-16 17:39 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from dominiq at lps dot ens dot fr 2010-04-16 17:38 -------
The run time error for
i = 0
a(i:1) = b(0:4)
is
At line 9 of file pr31538_db_2.f90
Fortran runtime error: Array bound mismatch, size mismatch for dimension 1 of
array 'a' (2/5)
for
i = 0
a(i:1) = f(b)
it is
At line 14 of file pr31538_db.f90
Fortran runtime error: Array bound mismatch for dimension 1 of array 'f'
In my opinion also the second case should produce an error similar to the first
ones.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31538
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/31538] misleading bounds check error
2007-04-11 15:08 [Bug fortran/31538] New: result_in_spec_1.f90: Invalid write burnus at gcc dot gnu dot org
` (8 preceding siblings ...)
2010-04-16 17:39 ` dominiq at lps dot ens dot fr
@ 2010-04-16 18:26 ` kargl at gcc dot gnu dot org
2010-04-17 21:06 ` kargl at gcc dot gnu dot org
` (2 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: kargl at gcc dot gnu dot org @ 2010-04-16 18:26 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from kargl at gcc dot gnu dot org 2010-04-16 18:25 -------
(In reply to comment #9)
> The run time error for
>
> i = 0
> a(i:1) = b(0:4)
>
> is
>
> At line 9 of file pr31538_db_2.f90
> Fortran runtime error: Array bound mismatch, size mismatch for dimension 1 of
> array 'a' (2/5)
>
> for
>
> i = 0
> a(i:1) = f(b)
>
> it is
>
> At line 14 of file pr31538_db.f90
> Fortran runtime error: Array bound mismatch for dimension 1 of array 'f'
>
> In my opinion also the second case should produce an error similar to the first
> ones.
>
How's this?
Unpatched gfortran:
laptop:kargl[205] gfc4x -o z -fcheck=bounds g.f90
laptop:kargl[206] ./z
At line 9 of file g.f90
Fortran runtime error: Array bound mismatch for dimension 1 of array 'f'
With a new patch:
laptop:kargl[211] gfc4x -o z -fcheck=bounds g.f90
laptop:kargl[212] ./z
At line 9 of file g.f90
Fortran runtime error: Dimension 1 of array 'f' has extent 5 instead of 6
laptop:kargl[213]
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31538
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/31538] misleading bounds check error
2007-04-11 15:08 [Bug fortran/31538] New: result_in_spec_1.f90: Invalid write burnus at gcc dot gnu dot org
` (9 preceding siblings ...)
2010-04-16 18:26 ` kargl at gcc dot gnu dot org
@ 2010-04-17 21:06 ` kargl at gcc dot gnu dot org
2010-04-17 22:13 ` kargl at gcc dot gnu dot org
2010-04-17 22:22 ` kargl at gcc dot gnu dot org
12 siblings, 0 replies; 14+ messages in thread
From: kargl at gcc dot gnu dot org @ 2010-04-17 21:06 UTC (permalink / raw)
To: gcc-bugs
------- Comment #11 from kargl at gcc dot gnu dot org 2010-04-17 21:06 -------
Subject: Bug 31538
Author: kargl
Date: Sat Apr 17 21:05:53 2010
New Revision: 158474
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158474
Log:
2010-04-17 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/31538
* gfortran.dg/bounds_check_fail_4.f90: Adjust error message.
* gfortran.dg/bounds_check_fail_3.f90: Ditto.
2010-04-17 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/31538
* fortran/trans-array.c (gfc_conv_ss_startstride): Remove the use of
gfc_msg_bounds by using 'Array bound mismatch' directly.
(gfc_trans_dummy_array_bias): Remove the use of gfc_msg_bounds. Reword
error message to include the mismatch in the extent of array bound.
* fortran/trans.c: Remove gfc_msg_bounds. It is only used in one place.
* fortran/trans.h: Remove extern definition of gfc_msg_bounds.
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/trans-array.c
trunk/gcc/fortran/trans.c
trunk/gcc/fortran/trans.h
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gfortran.dg/bounds_check_fail_3.f90
trunk/gcc/testsuite/gfortran.dg/bounds_check_fail_4.f90
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31538
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/31538] misleading bounds check error
2007-04-11 15:08 [Bug fortran/31538] New: result_in_spec_1.f90: Invalid write burnus at gcc dot gnu dot org
` (10 preceding siblings ...)
2010-04-17 21:06 ` kargl at gcc dot gnu dot org
@ 2010-04-17 22:13 ` kargl at gcc dot gnu dot org
2010-04-17 22:22 ` kargl at gcc dot gnu dot org
12 siblings, 0 replies; 14+ messages in thread
From: kargl at gcc dot gnu dot org @ 2010-04-17 22:13 UTC (permalink / raw)
To: gcc-bugs
------- Comment #12 from kargl at gcc dot gnu dot org 2010-04-17 22:12 -------
Fixed on 4.5 branch and trunk.
--
kargl at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.5.1
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31538
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/31538] misleading bounds check error
2007-04-11 15:08 [Bug fortran/31538] New: result_in_spec_1.f90: Invalid write burnus at gcc dot gnu dot org
` (11 preceding siblings ...)
2010-04-17 22:13 ` kargl at gcc dot gnu dot org
@ 2010-04-17 22:22 ` kargl at gcc dot gnu dot org
12 siblings, 0 replies; 14+ messages in thread
From: kargl at gcc dot gnu dot org @ 2010-04-17 22:22 UTC (permalink / raw)
To: gcc-bugs
------- Comment #13 from kargl at gcc dot gnu dot org 2010-04-17 22:22 -------
Subject: Bug 31538
Author: kargl
Date: Sat Apr 17 22:22:02 2010
New Revision: 158476
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158476
Log:
2010-04-17 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/31538
* gfortran.dg/bounds_check_fail_4.f90: Adjust error message.
* gfortran.dg/bounds_check_fail_3.f90: Ditto.
2010-04-17 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/31538
* fortran/trans-array.c (gfc_conv_ss_startstride): Remove the use of
gfc_msg_bounds by using 'Array bound mismatch' directly.
(gfc_trans_dummy_array_bias): Remove the use of gfc_msg_bounds. Reword
error message to include the mismatch in the extent of array bound.
* fortran/trans.c: Remove gfc_msg_bounds. It is only used in one place.
* fortran/trans.h: Remove extern definition of gfc_msg_bounds.
Modified:
branches/gcc-4_5-branch/gcc/fortran/ChangeLog
branches/gcc-4_5-branch/gcc/fortran/trans-array.c
branches/gcc-4_5-branch/gcc/fortran/trans.c
branches/gcc-4_5-branch/gcc/fortran/trans.h
branches/gcc-4_5-branch/gcc/testsuite/ChangeLog
branches/gcc-4_5-branch/gcc/testsuite/gfortran.dg/bounds_check_fail_3.f90
branches/gcc-4_5-branch/gcc/testsuite/gfortran.dg/bounds_check_fail_4.f90
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31538
^ permalink raw reply [flat|nested] 14+ messages in thread