This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/24462] New: packed-aligned structures are laid out differently


We have a binary incompatibility between 4.0.x and 4.1.x for:

struct B1_m_outer_p_inner {
  char c;
  double d;
} __attribute__ ((aligned)) __attribute__ ((packed));


Both fields are DECL_PACKED with 4.0.x:

 <record_type 0x2a959550d0 B1_m_outer_p_inner packed type_0 BLK
    size <integer_cst 0x2a95890d20 type <integer_type 0x2a9589a270
bit_size_type> constant invariant 128>
    unit size <integer_cst 0x2a95890d50 type <integer_type 0x2a9589a1a0 long
unsigned int> constant invariant 16>
    user align 128 symtab 0 alias set -1
    attributes <tree_list 0x2a9595ec30
        purpose <identifier_node 0x2a95959230 packed>
        chain <tree_list 0x2a9595ec00
            purpose <identifier_node 0x2a959591c0 aligned>>>
    fields <field_decl 0x2a95955270 c
        type <integer_type 0x2a9589a4e0 char public QI
            size <integer_cst 0x2a95890450 constant invariant 8>
            unit size <integer_cst 0x2a95890480 constant invariant 1>
            align 8 symtab 0 alias set -1 precision 8 min <integer_cst
0x2a95890510 -128> max <integer_cst 0x2a958905d0 127>
            pointer_to_this <pointer_type 0x2a958b0ea0>>
        packed QI file ../sa_x.c line 2 size <integer_cst 0x2a95890450 8> unit
size <integer_cst 0x2a95890480 1>
        align 8 offset_align 128
        offset <integer_cst 0x2a95890390 constant invariant 0>
        bit offset <integer_cst 0x2a958ac3c0 constant invariant 0> context
<record_type 0x2a959550d0 B1_m_outer_p_inner> arguments <integer_cst
0x2a95890390 0>
        chain <field_decl 0x2a95955340 d type <real_type 0x2a958add00 double>
            packed DF file ../sa_x.c line 3
            size <integer_cst 0x2a958909f0 constant invariant 64>
            unit size <integer_cst 0x2a95890a20 constant invariant 8>
            align 8 offset_align 128 offset <integer_cst 0x2a95890390 0> bit
offset <integer_cst 0x2a95890450 8> context <record_type 0x2a959550d0
B1_m_outer_p_inner> arguments <integer_cst 0x2a95890390 0>>>
    pointer_to_this <pointer_type 0x2a95955680> chain <type_decl 0x2a959551a0
D.1098>>

while none is with 4.1.x:

 <record_type 0x2a959719a0 B1_m_outer_p_inner packed type_0 BLK
    size <integer_cst 0x2a95891d20 type <integer_type 0x2a958a20b0
bit_size_type> constant invariant 128>
    unit size <integer_cst 0x2a95891d50 type <integer_type 0x2a958a2000 long
unsigned int> constant invariant 16>
    user align 128 symtab 0 alias set -1
    attributes <tree_list 0x2a9597ed80
        purpose <identifier_node 0x2a959775b0 packed>
        chain <tree_list 0x2a9597ed50
            purpose <identifier_node 0x2a95977540 aligned>>>
    fields <field_decl 0x2a9597f000 c
        type <integer_type 0x2a958a22c0 char public QI
            size <integer_cst 0x2a95891450 constant invariant 8>
            unit size <integer_cst 0x2a95891480 constant invariant 1>
            align 8 symtab 0 alias set -1 precision 8 min <integer_cst
0x2a95891510 -128> max <integer_cst 0x2a958915d0 127>
            pointer_to_this <pointer_type 0x2a958b1d10>>
        QI file ../sa_x.c line 2 size <integer_cst 0x2a95891450 8> unit size
<integer_cst 0x2a95891480 1>
        align 8 offset_align 128
        offset <integer_cst 0x2a95891390 constant invariant 0>
        bit offset <integer_cst 0x2a958ae3c0 constant invariant 0> context
<record_type 0x2a959719a0 B1_m_outer_p_inner>
        chain <field_decl 0x2a9597f0c0 d type <real_type 0x2a958b1420 double>
            DF file ../sa_x.c line 3
            size <integer_cst 0x2a958919f0 constant invariant 64>
            unit size <integer_cst 0x2a95891a20 constant invariant 8>
            align 8 offset_align 128 offset <integer_cst 0x2a95891390 0> bit
offset <integer_cst 0x2a95891450 8> context <record_type 0x2a959719a0
B1_m_outer_p_inner>>>
    pointer_to_this <pointer_type 0x2a95971c60> chain <type_decl 0x2a958afd00
D.1245>>


While the missing DECL_PACKED on the first field looks OK, DECL_PACKED on the
second field is required as the field start at bit offset 8.


-- 
           Summary: packed-aligned structures are laid out differently
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ebotcazou at gcc dot gnu dot org
 GCC build triplet: sparc64-*-*
  GCC host triplet: sparc64-*-*
GCC target triplet: sparc64-*-*


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24462


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]