Bug 18794 - warn about common variable alignment problems
Summary: warn about common variable alignment problems
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.0.0
: P2 enhancement
Target Milestone: 4.0.0
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks: 19292
  Show dependency treegraph
 
Reported: 2004-12-02 20:12 UTC by Thomas Koenig
Modified: 2005-04-20 02:00 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2004-12-02 21:01:49


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Koenig 2004-12-02 20:12:51 UTC
$ cat common.f
      program main
      character*1 c
      common /foo/ c,r
      c = 'a'
      r = 1.2
      end
$ g77 common.f
common.f: In program `main':
common.f:3: warning:
         common /foo/ c,r
                 ^
Initial padding for common block `foo' is 3 bytes at (^) -- consider
reorderingmembers, largest-type-size first
$ gfortran common.f
$ gfortran -v
Reading specs from /home/ig25/lib/gcc/i686-pc-linux-gnu/4.0.0/specs
Configured with: ../gcc/configure --prefix=/home/ig25
--enable-languages=c,c++,f95 : (reconfigured) ../gcc/configure
--prefix=/home/ig25 --with-gcc-version-trigger=/home/ig25/gcc/gcc/version.c
--enable-languages=c,c++,f95 --no-create --no-recursion
Thread model: posix
gcc version 4.0.0 20041129 (experimental)

Just about any Fortran compiler warns about this sort
of thing (and they should, the performance penalty
for this kind of thing can be severe).
Comment 1 Andrew Pinski 2004-12-02 21:01:49 UTC
Confirmed.
Comment 2 Thomas Koenig 2005-01-17 11:05:16 UTC
This is fixed with the 20050116 snapshot:

$ gfortran common.f
 In file common.f:3

      common /foo/ c,r
                 1
Warning: COMMON 'foo' at (1) requires 3 bytes of padding at start

        Thomas