[Bug c/50521] New: -fstrict-volatile-bitfields is not strict
kikairoya at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Sep 26 07:18:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50521
Bug #: 50521
Summary: -fstrict-volatile-bitfields is not strict
Classification: Unclassified
Product: gcc
Version: 4.6.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: kikairoya@gmail.com
gcc -fstrict-volatile-bitfields does not align volatile bitfield whose
bit-width=8, and generates byte-access code.
In this testcase:
// btf.c
volatile union {
unsigned int all;
struct {
unsigned int a: 8;
unsigned int : 7;
unsigned int b: 1;
unsigned int : 8;
unsigned int c: 8;
} bits;
} bitfield;
int main() {
bitfield.bits.b = 1;
bitfield.bits.c = 1;
return 0;
}
command line:
$ gcc -S -O -o - btf.c -fstrict-volatile-bitfields
...compiles to below:
.file "btf.c"
.text
.globl main
.type main, @function
main:
.LFB0:
.cfi_startproc
movl bitfield(%rip), %eax
orb $128, %ah
movl %eax, bitfield(%rip) ; ok, aligned 32bit access
movb $1, bitfield+3(%rip) ; *** byte access ***
movl $0, %eax
ret
.cfi_endproc
.LFE0:
.size main, .-main
.comm bitfield,4,4
.ident "GCC: (Debian 4.6.1-3) 4.6.1"
.section .note.GNU-stack,"",@progbits
other arch:
$ rx-elf-gcc -S -O -o - btf.c -fstrict-volatile-bitfields
.file "btf.c"
.section P,"ax"
.global _main
.type _main, @function
_main:
mov.L #_bitfield, r14
mov.L [r14], r4
bset #15, r4
mov.L r4, [r14] ; ok, aligned 32bit access
mov.B #1, 3[r14] ; *** byte access to misaligned address ***
mov.L #0, r1
rts
.size _main, .-_main
.comm _bitfield,4,4
.ident "GCC: (GNU) 4.6.1"
Can make this access aligned?
More information about the Gcc-bugs
mailing list