public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/66377] [F95] Wrong-code with equivalenced array in module
       [not found] <bug-66377-4@http.gcc.gnu.org/bugzilla/>
@ 2015-06-02 10:22 ` fxcoudert at gcc dot gnu.org
  2015-06-02 18:41 ` kargl at gcc dot gnu.org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2015-06-02 10:22 UTC (permalink / raw)
  To: gcc-bugs

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

Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-06-02
             Blocks|                            |32834
     Ever confirmed|0                           |1


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=32834
[Bug 32834] [Meta-bug] 'Fortran 95'-only failures


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

* [Bug fortran/66377] [F95] Wrong-code with equivalenced array in module
       [not found] <bug-66377-4@http.gcc.gnu.org/bugzilla/>
  2015-06-02 10:22 ` [Bug fortran/66377] [F95] Wrong-code with equivalenced array in module fxcoudert at gcc dot gnu.org
@ 2015-06-02 18:41 ` kargl at gcc dot gnu.org
  2015-06-02 19:04 ` sgk at troutmask dot apl.washington.edu
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-06-02 18:41 UTC (permalink / raw)
  To: gcc-bugs

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

kargl at gcc dot gnu.org changed:

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

--- Comment #1 from kargl at gcc dot gnu.org ---
Here's a slightly different testcase, which works as expected.

module constant
  integer x1, x2, y1, y2
  equivalence (y1,x1), (x2,y2)
end module

program test
  use constant
  y1 = 1
  x2 = 2
  call another()
contains
  subroutine another()
    use constant, only : x1, y2
    if (x1 /= 1 .or. x2 /= 2) call abort
  end subroutine
end program

Thus, there is something about the "arrayness" of x in
the original testcase that matters.  Off-by-one maybe?


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

* [Bug fortran/66377] [F95] Wrong-code with equivalenced array in module
       [not found] <bug-66377-4@http.gcc.gnu.org/bugzilla/>
  2015-06-02 10:22 ` [Bug fortran/66377] [F95] Wrong-code with equivalenced array in module fxcoudert at gcc dot gnu.org
  2015-06-02 18:41 ` kargl at gcc dot gnu.org
@ 2015-06-02 19:04 ` sgk at troutmask dot apl.washington.edu
  2015-06-02 23:37 ` sgk at troutmask dot apl.washington.edu
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2015-06-02 19:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Tue, Jun 02, 2015 at 06:41:53PM +0000, kargl at gcc dot gnu.org wrote:
> 
> Thus, there is something about the "arrayness" of x in
> the original testcase that matters.  Off-by-one maybe?
> 

There certainly is an appearance of off-by-one.

For the original testcase, if I use -fdump-tree-original
and remove the unessential portions of the dump, I get

another ()
{
  static integer(kind=4) x1   [value-expr: constant.eq.1.x1];
  static integer(kind=4) x[2] [value-expr: constant.eq.1.x];
}

test ()
{
  static integer(kind=4) x1   [value-expr: constant.eq.0.x1];
  static integer(kind=4) x2   [value-expr: constant.eq.0.x2];
  static integer(kind=4) x[2] [value-expr: constant.eq.0.x];
}

If I change

  subroutine another()
    use constant, only : x1
    if (x1 /= 1) call abort
  end subroutine

to

  subroutine another()
    use constant, only : x1,x
    if (x1 /= 1) call abort
  end subroutine

everything works.  The -fdump-tree-original then gives

another ()
{
  static integer(kind=4) x1   [value-expr: constant.eq.0.x1];
  static integer(kind=4) x2   [value-expr: constant.eq.0.x2];
  static integer(kind=4) x[2] [value-expr: constant.eq.0.x];
}

with the same reduced test().  I haven't checked on what
constant.eq.0.x versus constant.eq.1.x means.  Who's our
equivalence guru?


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

* [Bug fortran/66377] [F95] Wrong-code with equivalenced array in module
       [not found] <bug-66377-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2015-06-02 19:04 ` sgk at troutmask dot apl.washington.edu
@ 2015-06-02 23:37 ` sgk at troutmask dot apl.washington.edu
  2015-06-03  0:00 ` sgk at troutmask dot apl.washington.edu
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2015-06-02 23:37 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Tue, Jun 02, 2015 at 07:04:21PM +0000, sgk at troutmask dot
apl.washington.edu wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66377
> 
> --- Comment #2 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
> On Tue, Jun 02, 2015 at 06:41:53PM +0000, kargl at gcc dot gnu.org wrote:
> > 
> > Thus, there is something about the "arrayness" of x in
> > the original testcase that matters.  Off-by-one maybe?
> 
> There certainly is an appearance of off-by-one.
> 
> For the original testcase, if I use -fdump-tree-original
> and remove the unessential portions of the dump, I get
> 
> another ()
> {
>   static integer(kind=4) x1   [value-expr: constant.eq.1.x1];
>   static integer(kind=4) x[2] [value-expr: constant.eq.1.x];
> }
> 
> test ()
> {
>   static integer(kind=4) x1   [value-expr: constant.eq.0.x1];
>   static integer(kind=4) x2   [value-expr: constant.eq.0.x2];
>   static integer(kind=4) x[2] [value-expr: constant.eq.0.x];
> }
> 

OK.  Digging a little deeper.  The problem is in 
module.c (load_equiv).  There is a section of code
(lines 4526-4534) that tries to avoid loading unused
equivalenced symbols.  If those lines are commented
out, the original code works.

In looking at these lines and neighboring code, it looks
like an singly-linked list is constructed from the 
equivalence in the module file, but it is compressed due
to the missing (ie unused symbols).  So, it still suspect
a counting problem.


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

* [Bug fortran/66377] [F95] Wrong-code with equivalenced array in module
       [not found] <bug-66377-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2015-06-02 23:37 ` sgk at troutmask dot apl.washington.edu
@ 2015-06-03  0:00 ` sgk at troutmask dot apl.washington.edu
  2015-06-03 15:34 ` dominiq at lps dot ens.fr
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2015-06-03  0:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Tue, Jun 02, 2015 at 11:37:27PM +0000, sgk at troutmask dot
apl.washington.edu wrote:
> 
> OK.  Digging a little deeper.  The problem is in 
> module.c (load_equiv).  There is a section of code
> (lines 4526-4534) that tries to avoid loading unused
> equivalenced symbols.  If those lines are commented
> out, the original code works.
> 

Run gmake check-gfortran with the commented out
code does not cause any regressions.  The question
I guess is this some attempt at an optimization.


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

* [Bug fortran/66377] [F95] Wrong-code with equivalenced array in module
       [not found] <bug-66377-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2015-06-03  0:00 ` sgk at troutmask dot apl.washington.edu
@ 2015-06-03 15:34 ` dominiq at lps dot ens.fr
  2015-06-03 17:01 ` sgk at troutmask dot apl.washington.edu
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-06-03 15:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> Is this code old, or a regression introduced by the recent
> module-equivalence patch (to reduce the module sizes)?

It is at least as old as 4.3.1 and I am wondering if the code is valid!


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

* [Bug fortran/66377] [F95] Wrong-code with equivalenced array in module
       [not found] <bug-66377-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2015-06-03 15:34 ` dominiq at lps dot ens.fr
@ 2015-06-03 17:01 ` sgk at troutmask dot apl.washington.edu
  2015-06-03 18:22 ` sgk at troutmask dot apl.washington.edu
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2015-06-03 17:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Wed, Jun 03, 2015 at 03:34:09PM +0000, dominiq at lps dot ens.fr wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66377
> 
> --- Comment #6 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> > Is this code old, or a regression introduced by the recent
> > module-equivalence patch (to reduce the module sizes)?
> 
> It is at least as old as 4.3.1 and I am wondering if the code is valid!
> 

Are wondering about the Fortran code or the section of code
in module.c?  I cannot find anything in F2003 that would
suggest the Fortran code is invalid.  I suppose I could be
looking in the wrong place as the Standardese sometimes 
can be confusing.


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

* [Bug fortran/66377] [F95] Wrong-code with equivalenced array in module
       [not found] <bug-66377-4@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2015-06-03 17:01 ` sgk at troutmask dot apl.washington.edu
@ 2015-06-03 18:22 ` sgk at troutmask dot apl.washington.edu
  2015-06-03 20:32 ` sgk at troutmask dot apl.washington.edu
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2015-06-03 18:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Wed, Jun 03, 2015 at 06:43:40AM +0000, fxcoudert at gmail dot com wrote:
>
> Is this code old, or a regression introduced by the recent
> module-equivalence patch (to reduce the module sizes)?

It is old code that was introduced by r113465.  This
is nearly 9 years ago (2006-05-02).  The problem is present
in 4.7.x and up.  I don't have older versions for testing.

> Does removing the code regress module size in the case
> of modules with equiv used in modules used in modules etc?

I do not know.  I do not have a testcase handy unless there is
one in gfortran.dg.


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

* [Bug fortran/66377] [F95] Wrong-code with equivalenced array in module
       [not found] <bug-66377-4@http.gcc.gnu.org/bugzilla/>
                   ` (7 preceding siblings ...)
  2015-06-03 18:22 ` sgk at troutmask dot apl.washington.edu
@ 2015-06-03 20:32 ` sgk at troutmask dot apl.washington.edu
  2015-06-05 16:55 ` kargl at gcc dot gnu.org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2015-06-03 20:32 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Wed, Jun 03, 2015 at 11:21:35AM -0700, Steve Kargl wrote:
> 
> > Does removing the code regress module size in the case
> > of modules with equiv used in modules used in modules etc?
> 
> I do not know.  I do not have a testcase handy unless there is
> one in gfortran.dg.  
> 

OK.  I tracked down Russel's patch and testcase.  After
applying his patch and then removing the code in question,
I get want we want.  Namely, the code in this PR
compiles correctly and duplicate equivalences in a
hierarchy of modules are removed.


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

* [Bug fortran/66377] [F95] Wrong-code with equivalenced array in module
       [not found] <bug-66377-4@http.gcc.gnu.org/bugzilla/>
                   ` (8 preceding siblings ...)
  2015-06-03 20:32 ` sgk at troutmask dot apl.washington.edu
@ 2015-06-05 16:55 ` kargl at gcc dot gnu.org
  2015-06-05 20:41 ` kargl at gcc dot gnu.org
  2015-06-05 20:42 ` kargl at gcc dot gnu.org
  11 siblings, 0 replies; 12+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-06-05 16:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from kargl at gcc dot gnu.org ---
Author: kargl
Date: Fri Jun  5 16:54:53 2015
New Revision: 224159

URL: https://gcc.gnu.org/viewcvs?rev=224159&root=gcc&view=rev
Log:
2015-06-03  Russell Whitesides  <russelldub@gmail.com>
            Steven G. Kargl  <kargl@gcc.gnu.org>

        PR fortran/40958
        PR fortran/60780
        PR fortran/66377
        * module.c (load_equiv): Add check for loading duplicate EQUIVALENCEs
        from different modules.  Eliminate the pruning of unused
        equivalence-objects


2015-06-03  Steven G. Kargl  <kargl@gcc.gnu.org>

        PR fortran/66377
        gfortran.dg/equiv_9.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/equiv_9.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/module.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug fortran/66377] [F95] Wrong-code with equivalenced array in module
       [not found] <bug-66377-4@http.gcc.gnu.org/bugzilla/>
                   ` (9 preceding siblings ...)
  2015-06-05 16:55 ` kargl at gcc dot gnu.org
@ 2015-06-05 20:41 ` kargl at gcc dot gnu.org
  2015-06-05 20:42 ` kargl at gcc dot gnu.org
  11 siblings, 0 replies; 12+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-06-05 20:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from kargl at gcc dot gnu.org ---
Author: kargl
Date: Fri Jun  5 20:40:35 2015
New Revision: 224171

URL: https://gcc.gnu.org/viewcvs?rev=224171&root=gcc&view=rev
Log:
2015-06-03  Russell Whitesides  <russelldub@gmail.com>
            Steven G. Kargl  <kargl@gcc.gnu.org>

        PR fortran/40958
        PR fortran/60780
        PR fortran/66377
        * module.c (load_equiv): Add check for loading duplicate EQUIVALENCEs
        from different modules.  Eliminate the pruning of unused
        equivalence-objects


2015-06-03  Steven G. Kargl  <kargl@gcc.gnu.org>

        PR fortran/66377
        gfortran.dg/equiv_9.f90: New test.


Added:
    branches/gcc-5-branch/gcc/testsuite/gfortran.dg/equiv_9.f90
Modified:
    branches/gcc-5-branch/gcc/fortran/ChangeLog
    branches/gcc-5-branch/gcc/fortran/module.c
    branches/gcc-5-branch/gcc/testsuite/ChangeLog


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

* [Bug fortran/66377] [F95] Wrong-code with equivalenced array in module
       [not found] <bug-66377-4@http.gcc.gnu.org/bugzilla/>
                   ` (10 preceding siblings ...)
  2015-06-05 20:41 ` kargl at gcc dot gnu.org
@ 2015-06-05 20:42 ` kargl at gcc dot gnu.org
  11 siblings, 0 replies; 12+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-06-05 20:42 UTC (permalink / raw)
  To: gcc-bugs

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

kargl at gcc dot gnu.org changed:

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

--- Comment #12 from kargl at gcc dot gnu.org ---
Fixed on trunk and 5-branch.


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

end of thread, other threads:[~2015-06-05 20:42 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-66377-4@http.gcc.gnu.org/bugzilla/>
2015-06-02 10:22 ` [Bug fortran/66377] [F95] Wrong-code with equivalenced array in module fxcoudert at gcc dot gnu.org
2015-06-02 18:41 ` kargl at gcc dot gnu.org
2015-06-02 19:04 ` sgk at troutmask dot apl.washington.edu
2015-06-02 23:37 ` sgk at troutmask dot apl.washington.edu
2015-06-03  0:00 ` sgk at troutmask dot apl.washington.edu
2015-06-03 15:34 ` dominiq at lps dot ens.fr
2015-06-03 17:01 ` sgk at troutmask dot apl.washington.edu
2015-06-03 18:22 ` sgk at troutmask dot apl.washington.edu
2015-06-03 20:32 ` sgk at troutmask dot apl.washington.edu
2015-06-05 16:55 ` kargl at gcc dot gnu.org
2015-06-05 20:41 ` kargl at gcc dot gnu.org
2015-06-05 20:42 ` kargl 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).