[LLVMbugs] [Bug 18024] New: [-cxx-abi microsoft] clang ignores alignment specifier before class definition
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Nov 21 22:12:37 PST 2013
http://llvm.org/bugs/show_bug.cgi?id=18024
Bug ID: 18024
Summary: [-cxx-abi microsoft] clang ignores alignment specifier
before class definition
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: LLVM Codegen
Assignee: unassignedclangbugs at nondot.org
Reporter: david.majnemer at gmail.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
consider:
#include <stddef.h>
#include <stdio.h>
#include <string.h>
char buffer[419430400];
inline void *operator new(size_t, void *pv) { return pv; }
struct ClassName0 {
int ClassName0FieldName0;
ClassName0() {
printf("ClassName0FieldName0 : %llu\n", (unsigned long
long)((size_t)&ClassName0FieldName0 - (size_t)buffer));
}
};
#pragma pack(push, 8)
struct ClassName1: public ClassName0 {
char ClassName1FieldName0;
ClassName1() {
printf("ClassName1FieldName0 : %llu\n", (unsigned long
long)((size_t)&ClassName1FieldName0 - (size_t)buffer));
}
};
#pragma pack(pop)
struct ClassName2: public ClassName0 {
char ClassName2FieldName0;
ClassName2() {
printf("ClassName2FieldName0 : %llu\n", (unsigned long
long)((size_t)&ClassName2FieldName0 - (size_t)buffer));
}
};
__declspec(align(8192)) struct ClassName3: public ClassName1, public
ClassName2, public virtual ClassName0 {
float ClassName3FieldName0;
ClassName3() {
printf("ClassName3FieldName0 : %llu\n", (unsigned long
long)((size_t)&ClassName3FieldName0 - (size_t)buffer));
}
};
int main() {
memset(buffer, 0, sizeof(buffer));
new (buffer) ClassName0;
printf(" sizeof(ClassName0): %Iu\n", sizeof(ClassName0));
printf("__alignof(ClassName0): %Iu\n", __alignof(ClassName0));
memset(buffer, 0, sizeof(buffer));
new (buffer) ClassName1;
printf(" sizeof(ClassName1): %Iu\n", sizeof(ClassName1));
printf("__alignof(ClassName1): %Iu\n", __alignof(ClassName1));
memset(buffer, 0, sizeof(buffer));
new (buffer) ClassName2;
printf(" sizeof(ClassName2): %Iu\n", sizeof(ClassName2));
printf("__alignof(ClassName2): %Iu\n", __alignof(ClassName2));
memset(buffer, 0, sizeof(buffer));
new (buffer) ClassName3;
printf(" sizeof(ClassName3): %Iu\n", sizeof(ClassName3));
printf("__alignof(ClassName3): %Iu\n", __alignof(ClassName3));
}
msvc gives:
ClassName0FieldName0 : 0
sizeof(ClassName0): 4
__alignof(ClassName0): 4
ClassName0FieldName0 : 0
ClassName1FieldName0 : 4
sizeof(ClassName1): 8
__alignof(ClassName1): 4
ClassName0FieldName0 : 0
ClassName2FieldName0 : 4
sizeof(ClassName2): 8
__alignof(ClassName2): 4
ClassName0FieldName0 : 24
ClassName0FieldName0 : 0
ClassName1FieldName0 : 4
ClassName0FieldName0 : 8
ClassName2FieldName0 : 12
ClassName3FieldName0 : 20
sizeof(ClassName3): 8192
__alignof(ClassName3): 8192
clang gives:
ClassName0FieldName0 : 0
sizeof(ClassName0): 4
__alignof(ClassName0): 4
ClassName0FieldName0 : 0
ClassName1FieldName0 : 4
sizeof(ClassName1): 8
__alignof(ClassName1): 4
ClassName0FieldName0 : 0
ClassName2FieldName0 : 4
sizeof(ClassName2): 8
__alignof(ClassName2): 4
ClassName0FieldName0 : 24
ClassName0FieldName0 : 0
ClassName1FieldName0 : 4
ClassName0FieldName0 : 8
ClassName2FieldName0 : 12
ClassName3FieldName0 : 20
sizeof(ClassName3): 28
__alignof(ClassName3): 4
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20131122/3320a319/attachment.html>
More information about the llvm-bugs
mailing list