I am using ISO_C_BINDING to access 32-bit global variables in C object code from Fortran. In the C object code, globals are aligned at 4-byte boundaries, but Fortran object code expects 8-byte boundaries.
/* data.c */
integer(C_int), bind(C,name="global1") :: global1
end module globals
write (*,*) 'global1=',global1
$ icc -c data.c
$ ifort -c global.f90
$ ifort -o global global.o data.o
ld: Warning: alignment 4 of symbol `global1' in data.o is smaller than 8 in global.o
With the 32-bit compilers, both align at 4-byte boundaries. With 64-bit, Fortran switches to 8-byte boundaries, while icc and gcc both remain at 4-byte. I have tried passing various alignement switches to ifort, but get the same results.
The resulting code seems to work, so perhaps the linker can handle the problem and produce correct code. It would be nice to know if this warning can in fact be safely ignored, and if there are any compiler switches or directives to get the correct result. It also seems likely to be a compiler bug.
My compiler version is 12.1.0, running on a Fedora 15