Clang incompatible with GCC on Linux + ARM Cortex-A9

Hello,

I played with Clang + LLVM 3.1 release on ARM Linux and suspected it is incompatible with GCC. My program works fine while compiled using GCC but will crash with Clang. Specifically, the alignment strategy of Clang confused me. I wrote a small program to print the structure layout of the following and compiled it with both Clang and GCC.

struct S {
pthread_mutex_t mutex;
pthread_cond_t cond;
int32_t int32_1;
int32_t int32_2;
};

The output are as following (the format is: field_address (+offset): field_name; field_size):

gcc

0xbe92d588 (+0) : mutex ; 24
0xbe92d5a0 (+24): cond ; 48
0xbe92d5d0 (+72): int32_1 ; 4
0xbe92d5d4 (+76): int32_2 ; 4

clang

0xbe856580 (+0) : mutex ; 24
0xbe856598 (+24): cond ; 48
0xbe8565d0 (+80): int32_1 ; 4
0xbe8565d4 (+84): int32_2 ; 4

I don’t understand the way how Clang aligned int32_1. Why does Clang not align the field to 4 bytes but pad 8 bytes before it?

The problem is annoying as my program works fine with GCC but will crash with Clang. And I am unable to debug the Clang-compiled version since it is incompatible with GDB as well. I assume Clang should be compatible with GCC since they share the ABI (gnueabihf). Is this a bug in Clang+LLVM or that I did something wrong? Is there a way to get around this problem? Thank you!

4. Testing program code:

Please report a bug and attach the preprocessed source. Thanks.

I tried the most recent checkout from svn (revision 163071). It seems this bug has already been fixed. No need to report anymore:) Thank you.

- Lei