[LLVMbugs] [Bug 11655] New: clang alignment mismatch with gcc for ppc architecture

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Dec 27 00:44:10 PST 2011


http://llvm.org/bugs/show_bug.cgi?id=11655

             Bug #: 11655
           Summary: clang alignment mismatch with gcc for ppc architecture
           Product: clang
           Version: 2.9
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: mackyle at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Created attachment 7805
  --> http://llvm.org/bugs/attachment.cgi?id=7805
example.c file that demonstrates the issue

Items designated with "*" indicate a result from clang that differs from gcc.

#include <stddef.h>
#include <sys/sysctl.h>

CC='gcc-4.0'
  i386: offsetof(struct kinfo_proc,kp_eproc) = 196
   ppc: offsetof(struct kinfo_proc,kp_eproc) = 196
x86_64: offsetof(struct kinfo_proc,kp_eproc) = 296
 ppc64: offsetof(struct kinfo_proc,kp_eproc) = 296

CC='gcc-4.2'
  i386: offsetof(struct kinfo_proc,kp_eproc) = 196
   ppc: offsetof(struct kinfo_proc,kp_eproc) = 196
x86_64: offsetof(struct kinfo_proc,kp_eproc) = 296
 ppc64: offsetof(struct kinfo_proc,kp_eproc) = 296

clang version 2.9 (tags/RELEASE_29/final)
Target: i386-apple-darwin9
Thread model: posix
CC='clang'
  i386: offsetof(struct kinfo_proc,kp_eproc) = 196
   ppc: offsetof(struct kinfo_proc,kp_eproc) = 200 *
x86_64: offsetof(struct kinfo_proc,kp_eproc) = 296
 ppc64: offsetof(struct kinfo_proc,kp_eproc) = 296

Minimized example:

----- BEGIN example.c -----
/*
$CC -arch ppc -o example example.c
*/
#include <stddef.h>
#include <stdio.h>

struct badsize {
  long f0;
  long f1;
  long long f2;
  int f3;
  long long f4;
};

int main() {
  printf("offsetof(struct badsize,f4) = %d\n",
    (int)offsetof(struct badsize,f4));
  printf("  sizeof(struct badsize)    = %d\n",
    (int)sizeof(struct badsize));
  return 0;
}
----- END example.c -----

CC='gcc'
  i386: offsetof(struct badsize,f4) = 20
   ppc: offsetof(struct badsize,f4) = 20
x86_64: offsetof(struct badsize,f4) = 32
 ppc64: offsetof(struct badsize,f4) = 32

CC='clang'
  i386: offsetof(struct badsize,f4) = 20
   ppc: offsetof(struct badsize,f4) = 24 *
x86_64: offsetof(struct badsize,f4) = 32
 ppc64: offsetof(struct badsize,f4) = 32

CC='gcc'
  i386: sizeof(struct badsize) = 28
   ppc: sizeof(struct badsize) = 28
x86_64: sizeof(struct badsize) = 40
 ppc64: sizeof(struct badsize) = 40

CC='clang'
  i386: sizeof(struct badsize) = 28
   ppc: sizeof(struct badsize) = 32 *
x86_64: sizeof(struct badsize) = 40
 ppc64: sizeof(struct badsize) = 40


CC='gcc' sample.c output for -arch ppc:
offsetof(struct badsize,f4) = 20
  sizeof(struct badsize)    = 28

CC='clang' sample.c output for -arch ppc:
offsetof(struct badsize,f4) = 24 *
  sizeof(struct badsize)    = 32 *

The above issue makes it difficult to use clang as a gcc replacement for ppc
code.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list