public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/50521] New: -fstrict-volatile-bitfields is not strict
@ 2011-09-26  7:18 kikairoya at gmail dot com
  2011-09-26 11:43 ` [Bug c/50521] " rguenth at gcc dot gnu.org
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: kikairoya at gmail dot com @ 2011-09-26  7:18 UTC (permalink / raw)
  To: gcc-bugs

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?


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2011-10-29 14:37 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-26  7:18 [Bug c/50521] New: -fstrict-volatile-bitfields is not strict kikairoya at gmail dot com
2011-09-26 11:43 ` [Bug c/50521] " rguenth at gcc dot gnu.org
2011-09-26 12:08 ` kikairoya at gmail dot com
2011-09-27  8:22 ` kikairoya at gmail dot com
2011-10-20  1:54 ` kikairoya at gmail dot com
2011-10-27 23:23 ` henrik at henriknordstrom dot net
2011-10-28  1:33 ` kikairoya at gmail dot com
2011-10-28  2:00 ` henrik at henriknordstrom dot net
2011-10-28  3:59 ` kikairoya at gmail dot com
2011-10-28  7:34 ` henrik at henriknordstrom dot net
2011-10-28  8:13 ` kikairoya at gmail dot com
2011-10-28  8:15 ` kikairoya at gmail dot com
2011-10-28 17:46 ` henrik at henriknordstrom dot net
2011-10-29  6:50 ` kikairoya at gmail dot com
2011-10-29 10:46 ` henrik at henriknordstrom dot net
2011-10-29 14:37 ` kikairoya at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).