public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/58146] New: Array slice bounds checking
@ 2013-08-13  6:38 tkoenig at gcc dot gnu.org
  2013-08-13  6:38 ` [Bug fortran/58146] " tkoenig at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2013-08-13  6:38 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58146

            Bug ID: 58146
           Summary: Array slice bounds checking
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tkoenig at gcc dot gnu.org

The following doesn't trigger an error at compile time,
neither does it do so with -fcheck=all at runtime:

ig25@linux-fd1f:/tmp> cat diff.f90
program main
  implicit none
  integer :: n
  real, dimension(10) :: a
  n = 0
  call random_number(a)
  if (any(a(n+1:n+4) > [1.0, 2.0, 3.0])) print *,"Hello!"
end program main
ig25@linux-fd1f:/tmp> gfortran -fcheck=all diff.f90 
ig25@linux-fd1f:/tmp> ./a.out
ig25@linux-fd1f:/tmp>


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/58146] Array slice bounds checking
  2013-08-13  6:38 [Bug fortran/58146] New: Array slice bounds checking tkoenig at gcc dot gnu.org
@ 2013-08-13  6:38 ` tkoenig at gcc dot gnu.org
  2013-08-13 14:15 ` dominiq at lps dot ens.fr
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2013-08-13  6:38 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58146

Thomas Koenig <tkoenig at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
           Severity|normal                      |enhancement


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/58146] Array slice bounds checking
  2013-08-13  6:38 [Bug fortran/58146] New: Array slice bounds checking tkoenig at gcc dot gnu.org
  2013-08-13  6:38 ` [Bug fortran/58146] " tkoenig at gcc dot gnu.org
@ 2013-08-13 14:15 ` dominiq at lps dot ens.fr
  2013-08-13 22:08 ` tkoenig at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: dominiq at lps dot ens.fr @ 2013-08-13 14:15 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58146

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-08-13
     Ever confirmed|0                           |1

--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Confirmed.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/58146] Array slice bounds checking
  2013-08-13  6:38 [Bug fortran/58146] New: Array slice bounds checking tkoenig at gcc dot gnu.org
  2013-08-13  6:38 ` [Bug fortran/58146] " tkoenig at gcc dot gnu.org
  2013-08-13 14:15 ` dominiq at lps dot ens.fr
@ 2013-08-13 22:08 ` tkoenig at gcc dot gnu.org
  2013-08-13 22:55 ` tkoenig at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2013-08-13 22:08 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58146

Thomas Koenig <tkoenig at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |tkoenig at gcc dot gnu.org

--- Comment #2 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
Created attachment 30647
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30647&action=edit
Proposed patch

This should work for a compile-time check,
where this is possible.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/58146] Array slice bounds checking
  2013-08-13  6:38 [Bug fortran/58146] New: Array slice bounds checking tkoenig at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2013-08-13 22:08 ` tkoenig at gcc dot gnu.org
@ 2013-08-13 22:55 ` tkoenig at gcc dot gnu.org
  2013-08-14 16:56 ` mikael at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2013-08-13 22:55 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58146

--- Comment #3 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
Actually, the patch doesn't work (yet).

Working on it.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/58146] Array slice bounds checking
  2013-08-13  6:38 [Bug fortran/58146] New: Array slice bounds checking tkoenig at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2013-08-13 22:55 ` tkoenig at gcc dot gnu.org
@ 2013-08-14 16:56 ` mikael at gcc dot gnu.org
  2013-08-14 17:06 ` mikael at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mikael at gcc dot gnu.org @ 2013-08-14 16:56 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58146

Mikael Morin <mikael at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mikael at gcc dot gnu.org

--- Comment #4 from Mikael Morin <mikael at gcc dot gnu.org> ---
(In reply to Thomas Koenig from comment #0)
> neither does it do so with -fcheck=all at runtime:
> 
There is no out of bound at run time because the scalarizer sets the loop
bounds according to the array providing the most information; in this case the
constant array of size 3, so that the loop has only 3 iterations.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/58146] Array slice bounds checking
  2013-08-13  6:38 [Bug fortran/58146] New: Array slice bounds checking tkoenig at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2013-08-14 16:56 ` mikael at gcc dot gnu.org
@ 2013-08-14 17:06 ` mikael at gcc dot gnu.org
  2013-08-14 21:26 ` tkoenig at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mikael at gcc dot gnu.org @ 2013-08-14 17:06 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58146

--- Comment #5 from Mikael Morin <mikael at gcc dot gnu.org> ---
(In reply to Mikael Morin from comment #4)
> (In reply to Thomas Koenig from comment #0)
> > neither does it do so with -fcheck=all at runtime:
> > 
> There is no out of bound at run time because the scalarizer sets the loop
> bounds according to the array providing the most information; in this case
> the constant array of size 3, so that the loop has only 3 iterations.

This variant should trigger an out of bound runtime error, but it doesn't
either.

program main
  implicit none
  integer :: n
  real, dimension(4) :: a
  n = 0
  call random_number(a)
  if (any(a(n+1:n+4) > [1.0, 2.0, 3.0, 4.0, 5.0])) print *,"Hello!"
end program main


Technically a(n+1:n+4) is within the bounds, the out of bounds comes from the
loop with a 5-sized array.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/58146] Array slice bounds checking
  2013-08-13  6:38 [Bug fortran/58146] New: Array slice bounds checking tkoenig at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2013-08-14 17:06 ` mikael at gcc dot gnu.org
@ 2013-08-14 21:26 ` tkoenig at gcc dot gnu.org
  2013-08-27  9:52 ` mikael at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2013-08-14 21:26 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58146

--- Comment #6 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
(In reply to Mikael Morin from comment #5)

> Technically a(n+1:n+4) is within the bounds, the out of bounds comes from
> the loop with a 5-sized array.

The array expressions are not conformable, so it is a bounds
error either way.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/58146] Array slice bounds checking
  2013-08-13  6:38 [Bug fortran/58146] New: Array slice bounds checking tkoenig at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2013-08-14 21:26 ` tkoenig at gcc dot gnu.org
@ 2013-08-27  9:52 ` mikael at gcc dot gnu.org
  2013-08-27 11:31 ` mikael at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mikael at gcc dot gnu.org @ 2013-08-27  9:52 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58146

--- Comment #7 from Mikael Morin <mikael at gcc dot gnu.org> ---
Patch committed:

Author: tkoenig
Date: Sun Aug 25 22:55:12 2013
New Revision: 201981

URL: http://gcc.gnu.org/viewcvs?rev=201981&root=gcc&view=rev
Log:
2013-08-26  Thomas Koenig  <tkoenig@gcc.gnu.org>

    PR fortran/58146
    * array.c (gfc_ref_dimen_size):  If possible, use
    gfc_dep_difference to calculate array refrence
    sizes.  Fall back to integer code otherwise.
    * dependency.c (discard_nops).  Move up.
    Also discarde widening integer conversions.
    (gfc_dep_compare_expr):  Use discard_nops.

2013-08-26  Thomas Koenig  <tkoenig@gcc.gnu.org>

    PR fortran/58146
    * gfortran.dg/bounds_check_18.f90:  New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/bounds_check_18.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/array.c
    trunk/gcc/fortran/dependency.c
    trunk/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/58146] Array slice bounds checking
  2013-08-13  6:38 [Bug fortran/58146] New: Array slice bounds checking tkoenig at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2013-08-27  9:52 ` mikael at gcc dot gnu.org
@ 2013-08-27 11:31 ` mikael at gcc dot gnu.org
  2013-08-27 17:26 ` tkoenig at gcc dot gnu.org
  2023-09-18 21:37 ` anlauf at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: mikael at gcc dot gnu.org @ 2013-08-27 11:31 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58146

--- Comment #8 from Mikael Morin <mikael at gcc dot gnu.org> ---
Related bugs:
PR 50548, PR 33906


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/58146] Array slice bounds checking
  2013-08-13  6:38 [Bug fortran/58146] New: Array slice bounds checking tkoenig at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2013-08-27 11:31 ` mikael at gcc dot gnu.org
@ 2013-08-27 17:26 ` tkoenig at gcc dot gnu.org
  2023-09-18 21:37 ` anlauf at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2013-08-27 17:26 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58146

Thomas Koenig <tkoenig at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |NEW
           Assignee|tkoenig at gcc dot gnu.org         |unassigned at gcc dot gnu.org

--- Comment #9 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
Compile-time check done, runtime check
still to be done.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/58146] Array slice bounds checking
  2013-08-13  6:38 [Bug fortran/58146] New: Array slice bounds checking tkoenig at gcc dot gnu.org
                   ` (9 preceding siblings ...)
  2013-08-27 17:26 ` tkoenig at gcc dot gnu.org
@ 2023-09-18 21:37 ` anlauf at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-09-18 21:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58146

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |WAITING

--- Comment #10 from anlauf at gcc dot gnu.org ---
All testcases in this PR are covered.

There are other open PRs on bounds-checking.  Can we close this one?

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-09-18 21:37 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-13  6:38 [Bug fortran/58146] New: Array slice bounds checking tkoenig at gcc dot gnu.org
2013-08-13  6:38 ` [Bug fortran/58146] " tkoenig at gcc dot gnu.org
2013-08-13 14:15 ` dominiq at lps dot ens.fr
2013-08-13 22:08 ` tkoenig at gcc dot gnu.org
2013-08-13 22:55 ` tkoenig at gcc dot gnu.org
2013-08-14 16:56 ` mikael at gcc dot gnu.org
2013-08-14 17:06 ` mikael at gcc dot gnu.org
2013-08-14 21:26 ` tkoenig at gcc dot gnu.org
2013-08-27  9:52 ` mikael at gcc dot gnu.org
2013-08-27 11:31 ` mikael at gcc dot gnu.org
2013-08-27 17:26 ` tkoenig at gcc dot gnu.org
2023-09-18 21:37 ` 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).