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

             Bug #: 50120
           Summary: c_sizeof returns wrong value for struct
    Classification: Unclassified
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: simon.fu...@gmail.com


Created attachment 25053
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25053
A sample F90 file to demonstrate the problem.

c_sizeof gives the wrong values on bind(c) structs.

The attached program defines two structs s1 and s2 containing of an c_ptr and
of 1 and 2 c_ints, respectively. Then the size of these types is printed using
c_sizeof which gives:

c_sizeof s1:                    16
c_sizeof s2:                    16

For s1 I expect 8 (c_ptr) + 4 (c_int) = 12. 
For s2 I expect 8 (c_ptr) + 4 (c_int) + 4 (c_int) = 16. 


This bug was confirmed for 
gcc version 4.6.1 20110409 (prerelease) (Ubuntu 4.6.0-3~ppa1)
and
gcc version 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4)

Reply via email to