public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/57023] New: [4.7/4.8/4.9 Regression] Not packing arrays with changing variable used for size
@ 2013-04-21 11:13 tkoenig at gcc dot gnu.org
  2013-04-21 15:54 ` [Bug fortran/57023] " 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-04-21 11:13 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 57023
           Summary: [4.7/4.8/4.9 Regression] Not packing arrays with
                    changing variable used for size
    Classification: Unclassified
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: tkoenig@gcc.gnu.org


Doing what the program below does is _extremely_ bad style -
changing n which is used for specifying the array size.

However, I think it is legal, and the expected output
is

1 1 1 1 0
1 1 1 1 0
1 1 1 1 0
1 1 1 1 0
0 0 0 0 0

Actual output is

 1 1 1 1 1
 1 1 1 1 1
 1 1 1 1 1
 1 0 0 0 0
 0 0 0 0 0

module mymod
contains
  subroutine foo(a,n)
    integer, dimension(n,n), intent(inout) :: a
    integer :: n
    n = n - 1
    call baz(a(1:n,1:n),n)
  end subroutine foo

  subroutine baz(a,n)
    integer, dimension(n,n), intent(inout) :: a
    a = 1
  end subroutine baz
end module mymod

program main
  use mymod
  integer, dimension(5,5) :: a
  n = 5
  a = 0
  call foo(a,n)
  print '(5I2)',a
end program main

The problem is in gfc_full_array_ref_p, which uses gfc_dep_compare_expr
to compare the upper bounds (n against n) without noting that n
has been changed in the meantime.

Proposed solution:

a) Always warn about such horrible code

b) If something like that happens, don't assume a full reference,
   and don't set the contiguous argument to gfc_full_array_ref_p to
   true.

The code was introduced in rev. 156749, btw, quite some time ago.


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

* [Bug fortran/57023] [4.7/4.8/4.9 Regression] Not packing arrays with changing variable used for size
  2013-04-21 11:13 [Bug fortran/57023] New: [4.7/4.8/4.9 Regression] Not packing arrays with changing variable used for size tkoenig at gcc dot gnu.org
@ 2013-04-21 15:54 ` tkoenig at gcc dot gnu.org
  2013-04-21 21:07 ` burnus at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2013-04-21 15:54 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #2 from Thomas Koenig <tkoenig at gcc dot gnu.org> 2013-04-21 15:54:00 UTC ---
We also have to watch out for

module mymod
contains
  subroutine foo(a,n)
    integer, dimension(n,n), intent(inout) :: a
    integer :: n
    call decrement(n)
    call baz(a(1:n,1:n),n)
  end subroutine foo

  subroutine baz(a,n)
    integer, dimension(n,n), intent(inout) :: a
    a = 1
  end subroutine baz

  subroutine decrement(n)
    integer :: n
    n = n - 1
  end subroutine decrement
end module mymod

program main
  use mymod
  integer, dimension(5,5) :: a
  n = 5
  a = 0
  call foo(a,n)
  print '(5I2)',a
end program main


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

* [Bug fortran/57023] [4.7/4.8/4.9 Regression] Not packing arrays with changing variable used for size
  2013-04-21 11:13 [Bug fortran/57023] New: [4.7/4.8/4.9 Regression] Not packing arrays with changing variable used for size tkoenig at gcc dot gnu.org
  2013-04-21 15:54 ` [Bug fortran/57023] " tkoenig at gcc dot gnu.org
@ 2013-04-21 21:07 ` burnus at gcc dot gnu.org
  2013-10-25 12:54 ` rguenth at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-04-21 21:07 UTC (permalink / raw)
  To: gcc-bugs


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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu.org
   Target Milestone|---                         |4.7.4


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

* [Bug fortran/57023] [4.7/4.8/4.9 Regression] Not packing arrays with changing variable used for size
  2013-04-21 11:13 [Bug fortran/57023] New: [4.7/4.8/4.9 Regression] Not packing arrays with changing variable used for size tkoenig at gcc dot gnu.org
  2013-04-21 15:54 ` [Bug fortran/57023] " tkoenig at gcc dot gnu.org
  2013-04-21 21:07 ` burnus at gcc dot gnu.org
@ 2013-10-25 12:54 ` rguenth at gcc dot gnu.org
  2014-06-12 13:48 ` [Bug fortran/57023] [4.7/4.8/4.9/4.10 " rguenth at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-10-25 12:54 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4


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

* [Bug fortran/57023] [4.7/4.8/4.9/4.10 Regression] Not packing arrays with changing variable used for size
  2013-04-21 11:13 [Bug fortran/57023] New: [4.7/4.8/4.9 Regression] Not packing arrays with changing variable used for size tkoenig at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2013-10-25 12:54 ` rguenth at gcc dot gnu.org
@ 2014-06-12 13:48 ` rguenth at gcc dot gnu.org
  2014-12-19 13:42 ` [Bug fortran/57023] [4.8/4.9/5 " jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-06-12 13:48 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.7.4                       |4.8.4

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
The 4.7 branch is being closed, moving target milestone to 4.8.4.


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

* [Bug fortran/57023] [4.8/4.9/5 Regression] Not packing arrays with changing variable used for size
  2013-04-21 11:13 [Bug fortran/57023] New: [4.7/4.8/4.9 Regression] Not packing arrays with changing variable used for size tkoenig at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2014-06-12 13:48 ` [Bug fortran/57023] [4.7/4.8/4.9/4.10 " rguenth at gcc dot gnu.org
@ 2014-12-19 13:42 ` jakub at gcc dot gnu.org
  2015-01-19 21:25 ` tkoenig at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-12-19 13:42 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.8.4                       |4.8.5

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 4.8.4 has been released.


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

* [Bug fortran/57023] [4.8/4.9/5 Regression] Not packing arrays with changing variable used for size
  2013-04-21 11:13 [Bug fortran/57023] New: [4.7/4.8/4.9 Regression] Not packing arrays with changing variable used for size tkoenig at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2014-12-19 13:42 ` [Bug fortran/57023] [4.8/4.9/5 " jakub at gcc dot gnu.org
@ 2015-01-19 21:25 ` tkoenig at gcc dot gnu.org
  2015-01-20  7:03 ` tkoenig at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2015-01-19 21:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
I have something.  Let's see if it works...


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

* [Bug fortran/57023] [4.8/4.9/5 Regression] Not packing arrays with changing variable used for size
  2013-04-21 11:13 [Bug fortran/57023] New: [4.7/4.8/4.9 Regression] Not packing arrays with changing variable used for size tkoenig at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2015-01-19 21:25 ` tkoenig at gcc dot gnu.org
@ 2015-01-20  7:03 ` tkoenig at gcc dot gnu.org
  2015-01-21 19:41 ` tkoenig at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2015-01-20  7:03 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tkoenig at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |tkoenig at gcc dot gnu.org

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

This patch creates a temporary if a bound of the
array contains a dummy variable which is not
INTENT(IN) (so it could potentially be changed
by the user).

Modern code should always have INTENT(IN) for
something passed as array bounds, anyway.  We
should be correct for all cases, but not try
to optimize the pathological ones.


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

* [Bug fortran/57023] [4.8/4.9/5 Regression] Not packing arrays with changing variable used for size
  2013-04-21 11:13 [Bug fortran/57023] New: [4.7/4.8/4.9 Regression] Not packing arrays with changing variable used for size tkoenig at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2015-01-20  7:03 ` tkoenig at gcc dot gnu.org
@ 2015-01-21 19:41 ` tkoenig at gcc dot gnu.org
  2015-01-24 12:51 ` [Bug fortran/57023] [4.8/4.9 " tkoenig at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2015-01-21 19:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
Author: tkoenig
Date: Wed Jan 21 19:40:54 2015
New Revision: 219963

URL: https://gcc.gnu.org/viewcvs?rev=219963&root=gcc&view=rev
Log:
2015-01-21  Thomas Koenig  <tkoenig@netcologne.de>

    PR fortran/57023
    * dependency.c (callback_dummy_intent_not_int):  New function.
    (dummy_intent_not_in):  New function.
    (gfc_full_array_ref_p):  Use dummy_intent_not_in.

2015-01-21  Thomas Koenig  <tkoenig@netcologne.de>

    PR fortran/57023
    * gfortran.dg/internal_pack_15.f90:  New test.


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


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

* [Bug fortran/57023] [4.8/4.9 Regression] Not packing arrays with changing variable used for size
  2013-04-21 11:13 [Bug fortran/57023] New: [4.7/4.8/4.9 Regression] Not packing arrays with changing variable used for size tkoenig at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2015-01-21 19:41 ` tkoenig at gcc dot gnu.org
@ 2015-01-24 12:51 ` tkoenig at gcc dot gnu.org
  2015-01-24 15:21 ` [Bug fortran/57023] [4.8 " tkoenig at gcc dot gnu.org
  2015-01-24 15:22 ` tkoenig at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2015-01-24 12:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
Author: tkoenig
Date: Sat Jan 24 12:50:51 2015
New Revision: 220080

URL: https://gcc.gnu.org/viewcvs?rev=220080&root=gcc&view=rev
Log:
2015-01-24  Thomas Koenig  <tkoenig@netcologne.de>

    Backport from trunk
    PR fortran/57023
    * dependency.c (callback_dummy_intent_not_int):  New function.
    (dummy_intent_not_in):  New function.
    (gfc_full_array_ref_p):  Use dummy_intent_not_in.

2015-01-24  Thomas Koenig  <tkoenig@netcologne.de>

    Backport from trunk
    PR fortran/57023
    * gfortran.dg/internal_pack_15.f90:  New test.

Added:
    branches/gcc-4_9-branch/gcc/testsuite/gfortran.dg/internal_pack_15.f90
Modified:
    branches/gcc-4_9-branch/gcc/fortran/ChangeLog
    branches/gcc-4_9-branch/gcc/fortran/dependency.c
    branches/gcc-4_9-branch/gcc/testsuite/ChangeLog


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

* [Bug fortran/57023] [4.8 Regression] Not packing arrays with changing variable used for size
  2013-04-21 11:13 [Bug fortran/57023] New: [4.7/4.8/4.9 Regression] Not packing arrays with changing variable used for size tkoenig at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2015-01-24 12:51 ` [Bug fortran/57023] [4.8/4.9 " tkoenig at gcc dot gnu.org
@ 2015-01-24 15:21 ` tkoenig at gcc dot gnu.org
  2015-01-24 15:22 ` tkoenig at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2015-01-24 15:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
Author: tkoenig
Date: Sat Jan 24 15:20:56 2015
New Revision: 220082

URL: https://gcc.gnu.org/viewcvs?rev=220082&root=gcc&view=rev
Log:
2015-01-24  Thomas Koenig  <tkoenig@netcologne.de>

    Backport from trunk
    PR fortran/57023
    * dependency.c (callback_dummy_intent_not_int):  New function.
    (dummy_intent_not_in):  New function.
    (gfc_full_array_ref_p):  Use dummy_intent_not_in.

2015-01-24  Thomas Koenig  <tkoenig@netcologne.de>

    Backport from trunk
    PR fortran/57023
    * gfortran.dg/internal_pack_15.f90:  New test.


Modified:
    branches/gcc-4_8-branch/gcc/fortran/ChangeLog
    branches/gcc-4_8-branch/gcc/fortran/dependency.c
    branches/gcc-4_8-branch/gcc/testsuite/ChangeLog


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

* [Bug fortran/57023] [4.8 Regression] Not packing arrays with changing variable used for size
  2013-04-21 11:13 [Bug fortran/57023] New: [4.7/4.8/4.9 Regression] Not packing arrays with changing variable used for size tkoenig at gcc dot gnu.org
                   ` (9 preceding siblings ...)
  2015-01-24 15:21 ` [Bug fortran/57023] [4.8 " tkoenig at gcc dot gnu.org
@ 2015-01-24 15:22 ` tkoenig at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2015-01-24 15:22 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #10 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
Fixed on all open branches, closing.


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

end of thread, other threads:[~2015-01-24 15:22 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-21 11:13 [Bug fortran/57023] New: [4.7/4.8/4.9 Regression] Not packing arrays with changing variable used for size tkoenig at gcc dot gnu.org
2013-04-21 15:54 ` [Bug fortran/57023] " tkoenig at gcc dot gnu.org
2013-04-21 21:07 ` burnus at gcc dot gnu.org
2013-10-25 12:54 ` rguenth at gcc dot gnu.org
2014-06-12 13:48 ` [Bug fortran/57023] [4.7/4.8/4.9/4.10 " rguenth at gcc dot gnu.org
2014-12-19 13:42 ` [Bug fortran/57023] [4.8/4.9/5 " jakub at gcc dot gnu.org
2015-01-19 21:25 ` tkoenig at gcc dot gnu.org
2015-01-20  7:03 ` tkoenig at gcc dot gnu.org
2015-01-21 19:41 ` tkoenig at gcc dot gnu.org
2015-01-24 12:51 ` [Bug fortran/57023] [4.8/4.9 " tkoenig at gcc dot gnu.org
2015-01-24 15:21 ` [Bug fortran/57023] [4.8 " tkoenig at gcc dot gnu.org
2015-01-24 15:22 ` tkoenig 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).