[LLVMbugs] [Bug 15134] New: packed attribute confuses __transparent_union__
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Jan 31 23:37:06 PST 2013
http://llvm.org/bugs/show_bug.cgi?id=15134
Bug #: 15134
Summary: packed attribute confuses __transparent_union__
Product: clang
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: devel at fresse.org
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
Example:
#include <stdint.h>
#include <stdio.h>
union m30_u {
uint32_t u;
struct {
uint32_t expo:2;
uint32_t mant:30;
} __attribute__((packed));
} __attribute__((transparent_union));
typedef union m30_u m30_t;
static inline double
ffff_m30_d(m30_t m)
{
return (double)m.u;
}
int
main(int argc, char *argv[])
{
const uint32_t x = 1777U;
printf("%.6f\n", ffff_m30_d(x));
return 0;
}
freundt at clyde:pts/14:~/temp> clang -std=c99 transpu.c
transpu.c:6:2: warning: alignment of field '' (8 bits) does not match the
alignment of the first field in transparent union; transparent_union attribute
ignored [-Wignored-attributes]
struct {
^
transpu.c:5:11: note: alignment of first field is 32 bits
uint32_t u;
^
transpu.c:25:35: error: passing 'const uint32_t' (aka 'const unsigned int') to
parameter of incompatible type 'm30_t' (aka 'union m30_u')
printf("%.6f %zu\n", ffff_m30_d(x), sizeof(union m30_u));
^
transpu.c:15:18: note: passing argument to parameter 'm' here
ffff_m30_d(m30_t m)
^
1 warning and 1 error generated.
The packed attribute in the above example is superfluous, and once omitted the
example works.
freundt at clyde:pts/14:~/temp> clang --version
clang version 3.3 (trunk 169236)
Target: x86_64-unknown-linux-gnu
Thread model: posix
--
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