This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Christopher D. Rickett wrote:as mentioned previously on the list by Jack Howarth, there is a mismatch in alignment with bind(c) common blocks. the Fortran compiler simply sets the alignment of all common blocks to BIGGEST_ALIGN, while the C compiler tries to align based on the size of the fields in the interoperable C struct. the attached patch should fix the alignment difference by changing the alignment setting of bind(c) common blocks.
How often does this change something? It is a fairly widespread assumption that COMMON blocks can be mapped to C structs (e.g. I recall there being an example of doing this in the ROOT manual, and a quick websearch reveals lots of pages that describe this as a fact). I.e. that
COMMON /X/A,B,I(7),C
maps to
struct { float a, b; int i[7]; float c; }
etc.
Since this seems to be really common, I'm surprised that we weren't hit by this before.
I think we should choose C compatible alignments everywhere possible.
A testcase that triggers on i86 would also be a good idea.
Cheers, - Tobi
bootstrapped and regtested on x86 linux with no new failures.
ChangeLog entry:
2007-08-06 Christopher D. Rickett <crickett@lanl.gov>
* trans-common.c (build_common_decl): Fix the alignment for BIND(C) common blocks.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |