http://llvm.org/bugs/show_bug.cgi?id=19881
Bug ID: 19881
Summary: __attribute__((aligned(4))) must be placed in a
typedef for it to work.
Product: clang
Version: unspecified
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
Classification: Unclassified
Consider the following code:
#include <cstdint>
#include <stdio.h>
char data[256];
__attribute__((noinline)) double *getd()
{
char *ptr = (char*)(((uintptr_t)data + 7) & ~7); // Make 8-byte aligned
ptr += 4; // Now 4-byte aligned
double *d = (double*)ptr;
return d;
}
typedef double __attribute__((aligned(4))) double4;
int main()
{
double4 *d = getd(); // (*)
// double __attribute__((aligned(4))) *d = getd();
*d = 1.0;
printf("addr: %p, value: %f\n", d, *d);
}
in the resulting bitcode, the data pointed to by the variable d is properly
tracked as being aligned to 4 bytes (instead of being aligned to default 8
bytes).
If you instead replace the starred line (*) with the commented out line, i.e.
expand the typedef manually, then the attribute no longer works and it gets
ignored in the generated bitcode, and the alignment says 8 bytes.
It looks odd that the attribute must be used in a typedef in order to make it
work, is that a bug?
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs