public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/30689]  New: equivalence modifies common block
@ 2007-02-03 11:31 milan at cmm dot ki dot si
  2007-02-03 16:11 ` [Bug fortran/30689] " pault at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: milan at cmm dot ki dot si @ 2007-02-03 11:31 UTC (permalink / raw)
  To: gcc-bugs

I hope this is a new bug (I am not good at searching through bugzilla). I am
also not sure if this is according to standards, but as I undertand equivalence
is a harmless statement. It shouldn't change the lenght of the common block. I
am using gfortran -fdefault-integer-8 to compile gaussian-03 program on x86_64
machine. Everything works fine including GOMP stuff. Only the command to
reserve memory in the beginning doesn't work. One can use environment variable,
but it is annoying to tell every student, how to do it, so I decided to fix
also this and stumbled on the following problem:

      program lstint
      Implicit Integer(A-Z)
      REAL FP
      DOUBLE PRECISION DP
      COMMON/QPSTAT/LASTYP,STATUS,CHRCTR,DIGIT,Intger,FP,dp,LENSTR
      lenstr=15
      write(*,*)'QPtran>enter:lenstr=',lenstr
      Call QPutIt
      End
      Subroutine QPutIt
      Implicit Integer(A-Z)
      integer fpl,dpl(2)
      integer LASTYP,STATUS,CHRCTR,DIGIT,Intger,LENSTR
      Real FP
      Double Precision DP
      Common/QPStat/LASTYP,STATUS,CHRCTR,DIGIT,Intger,FP,DP,LENSTR
      Equivalence (DPL,DP),(FPL,FP)
      write(*,*)'QPutIt>start:lenstr=',lenstr
      return
      end

gfortran -fdefault-integer-8 -o x x.f
./x
lenstr=15
lenstr=0

Apparently the address of lenstr gets shifted in the subroutine because of the
equivalence statement. Is this the right behavior?


-- 
           Summary: equivalence modifies common block
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: milan at cmm dot ki dot si


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


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

* [Bug fortran/30689] equivalence modifies common block
  2007-02-03 11:31 [Bug fortran/30689] New: equivalence modifies common block milan at cmm dot ki dot si
@ 2007-02-03 16:11 ` pault at gcc dot gnu dot org
  2007-02-03 19:59 ` kargl at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-02-03 16:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pault at gcc dot gnu dot org  2007-02-03 16:11 -------

> Apparently the address of lenstr gets shifted in the subroutine because of the
> equivalence statement. Is this the right behavior?

This is what happens with my amd84:

$ /irun/bin/gfortran --version
GNU Fortran 95 (GCC) 4.3.0 20070202 (experimental)
Copyright (C) 2006 Free Software Foundation, Inc.

GNU Fortran comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of GNU Fortran
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING


Paul@NONE-X6EIN5I8FN /home/fortran
$ /irun/bin/gfortran -fdefault-integer-8 pr30689.f90
pr30689.f90:5.20:

      COMMON/QPSTAT/LASTYP,STATUS,CHRCTR,DIGIT,Intger,FP,dp,LENSTR
                   1
Warning: Padding of 4 bytes required before 'dp' in COMMON 'qpstat' at (1)
pr30689.f90:16.20:

      Common/QPStat/LASTYP,STATUS,CHRCTR,DIGIT,Intger,FP,DP,LENSTR
                   1
Warning: Padding of 12 bytes required before 'dp' in COMMON 'qpstat' at (1)
pr30689.f90:16.20:

      Common/QPStat/LASTYP,STATUS,CHRCTR,DIGIT,Intger,FP,DP,LENSTR
                   1
Warning: Named COMMON block 'qpstat' at (1) shall be of the same size

Paul


-- 


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


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

* [Bug fortran/30689] equivalence modifies common block
  2007-02-03 11:31 [Bug fortran/30689] New: equivalence modifies common block milan at cmm dot ki dot si
  2007-02-03 16:11 ` [Bug fortran/30689] " pault at gcc dot gnu dot org
@ 2007-02-03 19:59 ` kargl at gcc dot gnu dot org
  2007-02-03 23:52 ` milan at cmm dot ki dot si
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: kargl at gcc dot gnu dot org @ 2007-02-03 19:59 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from kargl at gcc dot gnu dot org  2007-02-03 19:59 -------
This is an invalid bug report.  -fdefault-integer-8 doesn't
do what you think it does.  If you use this option and equivalence
is present in the code, then you invariably want to use
-fdefault-real-8.


-- 

kargl at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

* [Bug fortran/30689] equivalence modifies common block
  2007-02-03 11:31 [Bug fortran/30689] New: equivalence modifies common block milan at cmm dot ki dot si
  2007-02-03 16:11 ` [Bug fortran/30689] " pault at gcc dot gnu dot org
  2007-02-03 19:59 ` kargl at gcc dot gnu dot org
@ 2007-02-03 23:52 ` milan at cmm dot ki dot si
  2007-02-04  0:13 ` milan at cmm dot ki dot si
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: milan at cmm dot ki dot si @ 2007-02-03 23:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from milan at cmm dot ki dot si  2007-02-03 23:52 -------
I am sorry for misunderstanding the program. I just took out of something big,
to show some weird behavior of COMMON and EQUIVALENCE. As you can imagine
-fdefault-integer-8 trick is the only solution to make those old 1 million line
of f77 code work in 64 bit machines. -fdefault-real-8 is not very good idea to
compile gaussian03. I don't want to change too much in this program, but I do
like gfortran for its speed over PGF. The weird behavior comes out if you
delete the equivalence line, then everything is OK. So with the equivalence
statement the COMMON block structure changes. And the program I put in the PR
is showing just this. Of course it doesn't do anything useful, but you don't
want to see the whole thing. I already fixed the stuff in gaussian program and
it works OK now, but I still think there is something strange going on in the
compiler to show this things or maybe I don't understand everything about the
equivalece statement. I am using Jan 19 snapshot and I see the same warnings as
Paul did and this and the wrong value of lenstr tells me that something is not
right. Apparently it works with other compilers (pgf, intel) because there are
a lot of testcases coming with gaussian03 package which would fail with this
code not working.

Is it right that any equivalence statement can change the lenght of a common
block?


-- 

milan at cmm dot ki dot si changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |


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


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

* [Bug fortran/30689] equivalence modifies common block
  2007-02-03 11:31 [Bug fortran/30689] New: equivalence modifies common block milan at cmm dot ki dot si
                   ` (2 preceding siblings ...)
  2007-02-03 23:52 ` milan at cmm dot ki dot si
@ 2007-02-04  0:13 ` milan at cmm dot ki dot si
  2007-02-04  2:27 ` kargl at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: milan at cmm dot ki dot si @ 2007-02-04  0:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from milan at cmm dot ki dot si  2007-02-04 00:13 -------
OK, maybe gfortran is right. It doesn't make much sense to me, but this is what
I found from wikipedia links in its fortran entry:

"Variables and arrays in common blocks can appear in EQUIVALENCE statements but
this has the effect of bringing all the associated items into the block. They
can be used to extend the contents of the block upwards, subject to the rules
for common block length, but not downwards."

So it seems that equivalence can change the size of common block :-(
In the next statement it also says that equivalence is mainly used to brake the
rules of fortran :-? So I am basically willing to give up on this and never
touch any equivalence stuff in the future :-)


-- 


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


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

* [Bug fortran/30689] equivalence modifies common block
  2007-02-03 11:31 [Bug fortran/30689] New: equivalence modifies common block milan at cmm dot ki dot si
                   ` (3 preceding siblings ...)
  2007-02-04  0:13 ` milan at cmm dot ki dot si
@ 2007-02-04  2:27 ` kargl at gcc dot gnu dot org
  2007-02-04 12:03 ` pault at gcc dot gnu dot org
  2007-02-04 22:57 ` milan at cmm dot ki dot si
  6 siblings, 0 replies; 8+ messages in thread
From: kargl at gcc dot gnu dot org @ 2007-02-04  2:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from kargl at gcc dot gnu dot org  2007-02-04 02:26 -------
(In reply to comment #4)
> OK, maybe gfortran is right.

It isn't that gfortran is right or wrong. :-)

The -fdefault-integer-8 changes the default integer kind to
an 8 byte integer.  The default real kind is still 4 bytes,
whereas the fortran standard requires that the default
real and integer kinds should occupy the same amount of 
storage. If you use both -fdefault-integer-8 and 
-fdefault-real-8 at the same time, everything magically
work.

And, yes, EQUIVALENCE is ugly and leads to a boat load
of problems.


-- 


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


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

* [Bug fortran/30689] equivalence modifies common block
  2007-02-03 11:31 [Bug fortran/30689] New: equivalence modifies common block milan at cmm dot ki dot si
                   ` (4 preceding siblings ...)
  2007-02-04  2:27 ` kargl at gcc dot gnu dot org
@ 2007-02-04 12:03 ` pault at gcc dot gnu dot org
  2007-02-04 22:57 ` milan at cmm dot ki dot si
  6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-02-04 12:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pault at gcc dot gnu dot org  2007-02-04 12:03 -------
I think that we can close this one, OK?

I've marked it as "invalid", although that seems a trifle unfair.

Please feel post bugs if you find them - we would rather discuss PRs like this
one than have disatisfied users out there!

Paul


-- 

pault at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

* [Bug fortran/30689] equivalence modifies common block
  2007-02-03 11:31 [Bug fortran/30689] New: equivalence modifies common block milan at cmm dot ki dot si
                   ` (5 preceding siblings ...)
  2007-02-04 12:03 ` pault at gcc dot gnu dot org
@ 2007-02-04 22:57 ` milan at cmm dot ki dot si
  6 siblings, 0 replies; 8+ messages in thread
From: milan at cmm dot ki dot si @ 2007-02-04 22:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from milan at cmm dot ki dot si  2007-02-04 22:56 -------
Subject: Re:  equivalence modifies common block

>>>>> "pault" == pault at gcc dot gnu dot org <gcc-bugzilla@gcc.gnu.org> writes:

    pault> ------- Comment #6 from pault at gcc dot gnu dot org
    pault> 2007-02-04 12:03 ------- I think that we can close this
    pault> one, OK?

    pault> I've marked it as "invalid", although that seems a trifle
    pault> unfair.

    pault> Please feel post bugs if you find them - we would rather
    pault> discuss PRs like this one than have disatisfied users out
    pault> there!

Yes it is OK to close it. I am sorry to bother you with this one, but
I was thinking if it works with other compilers it should with
gfortran, too. But then it is not very clear how the others do it, and
I am not too much interested into other compilers, anyway. Thanks for
helping me shed some new light in fortran tricks :-)

Milan


-- 


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


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

end of thread, other threads:[~2007-02-04 22:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-03 11:31 [Bug fortran/30689] New: equivalence modifies common block milan at cmm dot ki dot si
2007-02-03 16:11 ` [Bug fortran/30689] " pault at gcc dot gnu dot org
2007-02-03 19:59 ` kargl at gcc dot gnu dot org
2007-02-03 23:52 ` milan at cmm dot ki dot si
2007-02-04  0:13 ` milan at cmm dot ki dot si
2007-02-04  2:27 ` kargl at gcc dot gnu dot org
2007-02-04 12:03 ` pault at gcc dot gnu dot org
2007-02-04 22:57 ` milan at cmm dot ki dot si

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).