<html>
<head>
<base href="http://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - [ABI] powerpc-darwin struct layout incorrect"
href="http://llvm.org/bugs/show_bug.cgi?id=18889">18889</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[ABI] powerpc-darwin struct layout incorrect
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Macintosh
</td>
</tr>
<tr>
<th>OS</th>
<td>MacOS X
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Keywords</th>
<td>ABI
</td>
</tr>
<tr>
<th>Severity</th>
<td>release blocker
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Backend: PowerPC
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>fang@csl.cornell.edu
</td>
</tr>
<tr>
<th>CC</th>
<td>iains-llvm@btconnect.com, llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Iain shared some test cases that expose some differences between struct layout
in gcc (apple's system) and clang, both with PowerPC32. These are high
priority fixes.
Case 0:
// "structs-0.c"
#include <stdbool.h>
struct _L {
long long L;
} L;
struct _b {
_Bool b;
} b;
struct _c {
char c;
} c;
struct _s {
short s;
} s;
struct _i {
int i;
} i;
struct _l {
long l;
} l;
struct _f {
float f;
} f;
struct _d {
double d;
} d;
struct _D {
long double D;
} D;
#ifdef MAIN
#include <stdint.h>
#include <stdio.h>
int main (void)
{
printf ("sizes : b %ld c %ld s %ld i %ld l %ld ll %ld f %ld d %ld ld
%ld\n",
sizeof(_Bool), sizeof(char), sizeof(short), sizeof(int), sizeof(long),
sizeof(long long), sizeof(float), sizeof(double), sizeof(long double));
printf ("aligns : b %ld c %ld s %ld i %ld l %ld ll %ld f %ld d %ld ld
%ld\n",
__alignof__(_Bool), __alignof__(char), __alignof__(short),
__alignof__(int), __alignof__(long), __alignof__(long long),
__alignof__(float), __alignof__(double), __alignof__(long double));
printf ("s-size : b %ld c %ld s %ld i %ld l %ld ll %ld f %ld d %ld ld
%ld\n",
sizeof(b), sizeof(c), sizeof(s),
sizeof(i), sizeof(l), sizeof(L),
sizeof(f), sizeof(d), sizeof(D));
printf ("s-align : b %ld c %ld s %ld i %ld l %ld ll %ld f %ld d %ld ld
%ld\n",
__alignof__(b), __alignof__(c), __alignof__(s),
__alignof__(i), __alignof__(l), __alignof__(L),
__alignof__(f), __alignof__(d), __alignof__(D));
return 0;
}
#endif
----
differences:
--- structs-0.gcc-out 2014-02-18 13:43:45.000000000 -0800
+++ structs-0.clang-out 2014-02-18 13:43:45.000000000 -0800
@@ -1,4 +1,4 @@
sizes : b 4 c 1 s 2 i 4 l 4 ll 8 f 4 d 8 ld 16
aligns : b 4 c 1 s 2 i 4 l 4 ll 8 f 4 d 8 ld 16
s-size : b 4 c 1 s 2 i 4 l 4 ll 8 f 4 d 8 ld 16
-s-align : b 4 c 1 s 2 i 4 l 4 ll 8 f 4 d 8 ld 16
+s-align : b 4 c 1 s 2 i 4 l 4 ll 4 f 4 d 8 ld 16
case 1:
// "structs-1.c"
struct _cd {
char c;
double d;
} cd;
struct _dc {
double d;
char c;
} dc;
struct _cL {
char c;
long long L;
} cL;
struct _Lc {
long long L;
char c;
} Lc;
struct _cScd {
char c;
struct _cd Scd;
} cScd;
struct _cSdc {
char c;
struct _dc Sdc;
} cSdc;
struct _cScL {
char c;
struct _cL ScL;
} cScL;
struct _cSLc {
char c;
struct _Lc SLc;
} cSLc;
#ifdef MAIN
#include <stdint.h>
#include <stdio.h>
int main (void)
{
printf ("s-size : cd %ld dc %ld cL %ld Lc %ld cScd %ld cSdc %ld cScL %ld
cSLc %ld\n",
sizeof(cd), sizeof(dc), sizeof(cL), sizeof(Lc),
sizeof(cScd), sizeof(cSdc), sizeof(cScL), sizeof(cSLc));
printf ("s-align : cd %ld dc %ld cL %ld Lc %ld cScd %ld cSdc %ld cScL %ld
cSLc %ld\n",
__alignof__(cd), __alignof__(dc), __alignof__(cL), __alignof__(Lc),
__alignof__(cScd), __alignof__(cSdc), __alignof__(cScL),
__alignof__(cSLc));
return 0;
}
#endif
----
differences:
--- structs-1.gcc-out 2014-02-18 13:43:45.000000000 -0800
+++ structs-1.clang-out 2014-02-18 13:43:45.000000000 -0800
@@ -1,2 +1,2 @@
-s-size : cd 12 dc 16 cL 12 Lc 16 cScd 16 cSdc 20 cScL 16 cSLc 20
-s-align : cd 4 dc 8 cL 4 Lc 8 cScd 4 cSdc 4 cScL 4 cSLc 4
+s-size : cd 16 dc 16 cL 12 Lc 12 cScd 24 cSdc 24 cScL 16 cSLc 16
+s-align : cd 8 dc 8 cL 4 Lc 4 cScd 8 cSdc 8 cScL 4 cSLc 4
--------------------
Iain has some patches that address this. I plan to help convert these test
cases to use dump-record-layout and FileCheck.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>