Bug 18794

Summary: warn about common variable alignment problems
Product: gcc Reporter: Thomas Koenig <Thomas.Koenig>
Component: fortranAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: enhancement CC: gcc-bugs
Priority: P2 Keywords: diagnostic
Version: 4.0.0   
Target Milestone: 4.0.0   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2004-12-02 21:01:49
Bug Depends on:    
Bug Blocks: 19292    

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