public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/37614]  New: Change position of padding for aligned COMMONs
@ 2008-09-22 13:29 burnus at gcc dot gnu dot org
  2008-10-25  8:28 ` [Bug fortran/37614] " tkoenig at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-09-22 13:29 UTC (permalink / raw)
  To: gcc-bugs

Follow up to PR 37486.
see also http://gcc.gnu.org/ml/fortran/2008-09/msg00366.html

The following program should print "5" but it prints "0" with default options
in gfortran. The problem is that in the program, the common object is padded as
   <4bytes padding> + i + r8
and then in the subroutine, only the first 4 bytes are read and assigned to the
local variable "i".

The program is valid as "Named common blocks of the same name shall be of the
same size in all scoping units of a program in which they appear, but blank
common blocks may be of different sizes."

As tests with NAG f95, Portland pgf95 and Pathscale pathf95 show, these
compilers use
  i + <4bytes padding> + r8
which allows this program to run correctly without sacrificing the alignment. 

(ifort, sunf95 and g95 - and "gfortran -fno-align-commons" work as no padding
is added.)

There are still used but not standard conform versions which fail (cf. examples
in PR 37486) but for those, gfortran has -fno-align-commons.


Test program:
----------------------------------------
subroutine one()
  integer :: i, j
  common i
  print *, i ! shall print "5", in gfortran it is "0"
!
! Testing alternative (invalid standard Fortran):
!  common i,j
!  print *, i,j
end subroutine one

program test
  integer :: i
  real*8 r8
  common i, r8
  i = 5
  r8 = 123457891234d88
  call one()
end program test
----------------------------------------

If one enables the "common  i, j" and runs the program with several compilers,
details about their implementation is revealed:

- gfortran and g77 print "0 5"
- ifort, sunf95 and g95 print "5 1267487353" (= gfortran -fno-align-commons)
- pathscale, pgi, and NAG f95 print "5 0" << expected result when PR is fixed


-- 
           Summary: Change position of padding for aligned COMMONs
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


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


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

* [Bug fortran/37614] Change position of padding for aligned COMMONs
  2008-09-22 13:29 [Bug fortran/37614] New: Change position of padding for aligned COMMONs burnus at gcc dot gnu dot org
@ 2008-10-25  8:28 ` tkoenig at gcc dot gnu dot org
  2009-01-15  9:19 ` pault at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2008-10-25  8:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from tkoenig at gcc dot gnu dot org  2008-10-25 08:26 -------
This would mean an ABI change, but it is worth thinking about.


-- 

tkoenig at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2008-10-25 08:26:57
               date|                            |


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


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

* [Bug fortran/37614] Change position of padding for aligned COMMONs
  2008-09-22 13:29 [Bug fortran/37614] New: Change position of padding for aligned COMMONs burnus at gcc dot gnu dot org
  2008-10-25  8:28 ` [Bug fortran/37614] " tkoenig at gcc dot gnu dot org
@ 2009-01-15  9:19 ` pault at gcc dot gnu dot org
  2009-01-27 20:53 ` [Bug fortran/37614] [Fix pending] " pault at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pault at gcc dot gnu dot org @ 2009-01-15  9:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pault at gcc dot gnu dot org  2009-01-15 09:19 -------
(In reply to comment #1)
> This would mean an ABI change, but it is worth thinking about.
> 

The required fix is trivial, although I have not regtested yet; eliminate
1127-1131 in trans-common.c.

Cheers

Paul


-- 

pault at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |pault at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2008-10-25 08:26:57         |2009-01-15 09:19:04
               date|                            |


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


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

* [Bug fortran/37614] [Fix pending] Change position of padding for aligned COMMONs
  2008-09-22 13:29 [Bug fortran/37614] New: Change position of padding for aligned COMMONs burnus at gcc dot gnu dot org
  2008-10-25  8:28 ` [Bug fortran/37614] " tkoenig at gcc dot gnu dot org
  2009-01-15  9:19 ` pault at gcc dot gnu dot org
@ 2009-01-27 20:53 ` pault at gcc dot gnu dot org
  2009-04-04 16:42 ` [Bug fortran/37614] " pault at gcc dot gnu dot org
  2009-04-04 16:48 ` pault at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: pault at gcc dot gnu dot org @ 2009-01-27 20:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pault at gcc dot gnu dot org  2009-01-27 20:53 -------
See http://gcc.gnu.org/ml/fortran/2009-01/msg00217.html and subsequent
postings.

Paul


-- 

pault at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Change position of padding  |[Fix pending] Change
                   |for aligned COMMONs         |position of padding for
                   |                            |aligned COMMONs


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


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

* [Bug fortran/37614] Change position of padding for aligned COMMONs
  2008-09-22 13:29 [Bug fortran/37614] New: Change position of padding for aligned COMMONs burnus at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2009-01-27 20:53 ` [Bug fortran/37614] [Fix pending] " pault at gcc dot gnu dot org
@ 2009-04-04 16:42 ` pault at gcc dot gnu dot org
  2009-04-04 16:48 ` pault at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: pault at gcc dot gnu dot org @ 2009-04-04 16:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pault at gcc dot gnu dot org  2009-04-04 16:41 -------
Subject: Bug 37614

Author: pault
Date: Sat Apr  4 16:41:30 2009
New Revision: 145541

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=145541
Log:
2009-04-04  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/37614
        * trans-common.c (translate_common): Do not offset the whole
        coomon block.

2009-04-04  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/37614
        * gfortran.dg/common_align_2.f90: New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/common_align_2.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-common.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug fortran/37614] Change position of padding for aligned COMMONs
  2008-09-22 13:29 [Bug fortran/37614] New: Change position of padding for aligned COMMONs burnus at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2009-04-04 16:42 ` [Bug fortran/37614] " pault at gcc dot gnu dot org
@ 2009-04-04 16:48 ` pault at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: pault at gcc dot gnu dot org @ 2009-04-04 16:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pault at gcc dot gnu dot org  2009-04-04 16:47 -------
Fixed on 4.5.  Because of the ABI change, I will not backport this unless there
is an overwhelming public demand.  Equally, the desire for an option to revert
it, -fg77-common-align, will only be implemented if there is demand for it.

Thanks for the report.

Paul


-- 

pault at gcc dot gnu dot org changed:

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


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


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

end of thread, other threads:[~2009-04-04 16:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-22 13:29 [Bug fortran/37614] New: Change position of padding for aligned COMMONs burnus at gcc dot gnu dot org
2008-10-25  8:28 ` [Bug fortran/37614] " tkoenig at gcc dot gnu dot org
2009-01-15  9:19 ` pault at gcc dot gnu dot org
2009-01-27 20:53 ` [Bug fortran/37614] [Fix pending] " pault at gcc dot gnu dot org
2009-04-04 16:42 ` [Bug fortran/37614] " pault at gcc dot gnu dot org
2009-04-04 16:48 ` pault at gcc dot gnu dot 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).