https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97840

Jan Hubicka <hubicka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |msebor at gcc dot gnu.org

--- Comment #3 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
OK, on x86_64 the corresponding warning does not trigger since TYPE_EMPTY_P is
true.

x86_64 compiler I get:
(gdb) p debug_tree (rhstype)
 <record_type 0x7ffff7624498 allocator sizes-gimplified addressable
needs-constructing cxx-odr-p type_1 type_4 type_5 type_6 BLK
    size <integer_cst 0x7ffff744af90 type <integer_type 0x7ffff74690a8
bitsizetype> constant 8>
    unit-size <integer_cst 0x7ffff744afa8 type <integer_type 0x7ffff7469000
sizetype> constant 1>
    align:8 warn_if_not_align:0 symtab:0 alias-set 76 canonical-type
0x7ffff7624498
    fields <field_decl 0x7ffff685a1c8 D.14377
        type <record_type 0x7ffff684a888 new_allocator sizes-gimplified
addressable needs-constructing cxx-odr-p type_1 type_4 type_5 type_6 BLK size
<integer_cst 0x7ffff744af90 8> unit-size <integer_cst 0x7ffff744afa8 1>
            align:8 warn_if_not_align:0 symtab:0 alias-set 77 canonical-type
0x7ffff684a888 fields <function_decl 0x7ffff6858500 operator=> context
<namespace_decl 0x7ffff7478b48 __gnu_cxx>
            full-name "class __gnu_cxx::new_allocator<char>"
            needs-constructor needs-destructor X() X(constX&) this=(X&)
n_parents=0 use_template=1 interface-unknown
            pointer_to_this <pointer_type 0x7ffff684f000> reference_to_this
<reference_type 0x7ffff685b738> chain <type_decl 0x7ffff6845c78 new_allocator>>
        ignored decl_6 BLK
/opt/gcc/test/Build/aarch64-suse-linux/libstdc++-v3/include/bits/allocator.h:116:11
        size <integer_cst 0x7ffff744aed0 constant 0> unit-size <integer_cst
0x7ffff744aed0 0>
        align:8 warn_if_not_align:0 offset_align 8 offset <integer_cst
0x7ffff744aed0 0>
        bit-offset <integer_cst 0x7ffff744af18 constant 0> context <record_type
0x7ffff7624498 allocator>
        chain <template_decl 0x7ffff6855b00 rebind type <record_type
0x7ffff6854a80 rebind>
            ignored decl_1 VOID
/opt/gcc/test/Build/aarch64-suse-linux/libstdc++-v3/include/bits/allocator.h:129:9
            align:1 warn_if_not_align:0 context <record_type 0x7ffff7624498
allocator>
            parms <tree_list 0x7ffff6859208 purpose <integer_cst 0x7ffff744afa8
1>
                value <tree_vec 0x7ffff6856980 type <template_decl
0x7ffff6855b00 rebind>
                    length:1
                    elt:0 <tree_list 0x7ffff68591e0 value <type_decl
0x7ffff684de40 _Tp1>>>>
            full-name "template<class _Tp1> struct
std::allocator<char>::rebind" chain <function_decl 0x7ffff6858200 __ct >>>
context <namespace_decl 0x7ffff7466098 std>
    full-name "class std::allocator<char>"
    needs-constructor needs-destructor X() X(constX&) this=(X&) n_parents=1
use_template=3 interface-only
    pointer_to_this <pointer_type 0x7ffff685b0a8> reference_to_this
<reference_type 0x7ffff685b5e8> chain <type_decl 0x7ffff76238e8 allocator>>
$50 = void
(gdb) p rhstype->type_common.empty_flag
$51 = 1


while on aarch64 I get:

(gdb) p debug_tree (rhstype)
 <record_type 0x7ffff71ff3f0 allocator sizes-gimplified addressable
needs-constructing cxx-odr-p type_1 type_4 type_5 type_6 BLK
    size <integer_cst 0x7ffff7466030 type <integer_type 0x7ffff74640a8
bitsizetype> constant 8>
    unit-size <integer_cst 0x7ffff7466048 type <integer_type 0x7ffff7464000
sizetype> constant 1>
    align:8 warn_if_not_align:0 symtab:0 alias-set 76 canonical-type
0x7ffff71ff3f0
    fields <field_decl 0x7ffff6636688 D.16017
        type <record_type 0x7ffff66297e0 new_allocator sizes-gimplified
addressable needs-constructing cxx-odr-p type_1 type_4 type_5 type_6 BLK size
<integer_cst 0x7ffff7466030 8> unit-size <integer_cst 0x7ffff7466048 1>
            align:8 warn_if_not_align:0 symtab:0 alias-set 77 canonical-type
0x7ffff66297e0 fields <function_decl 0x7ffff6639300 operator=> context
<namespace_decl 0x7ffff7186428 __gnu_cxx>
            full-name "class __gnu_cxx::new_allocator<char>"
            needs-constructor needs-destructor X() X(constX&) this=(X&)
n_parents=0 use_template=1 interface-unknown
            pointer_to_this <pointer_type 0x7ffff6629690> reference_to_this
<reference_type 0x7ffff6638690> chain <type_decl 0x7ffff662a1c8 new_allocator>>
        ignored decl_6 BLK
/opt/gcc/test/Build/aarch64-suse-linux/libstdc++-v3/include/bits/allocator.h:116:11
        size <integer_cst 0x7ffff744af60 constant 0> unit-size <integer_cst
0x7ffff744af60 0>
        align:8 warn_if_not_align:0 offset_align 8 offset <integer_cst
0x7ffff744af60 0>
        bit-offset <integer_cst 0x7ffff744afa8 constant 0> context <record_type
0x7ffff71ff3f0 allocator>
        chain <template_decl 0x7ffff6635b00 rebind type <record_type
0x7ffff6634930 rebind>
            ignored decl_1 VOID
/opt/gcc/test/Build/aarch64-suse-linux/libstdc++-v3/include/bits/allocator.h:129:9
            align:1 warn_if_not_align:0 context <record_type 0x7ffff71ff3f0
allocator>
            parms <tree_list 0x7ffff6633898 purpose <integer_cst 0x7ffff7466048
1>
                value <tree_vec 0x7ffff6637020 type <template_decl
0x7ffff6635b00 rebind>
                    length:1
                    elt:0 <tree_list 0x7ffff6633870 value <type_decl
0x7ffff6636390 _Tp1>>>>
            full-name "template<class _Tp1> struct
std::allocator<char>::rebind" chain <function_decl 0x7ffff6639000 __ct >>>
context <namespace_decl 0x7ffff7460098 std>
    full-name "class std::allocator<char>"
    needs-constructor needs-destructor X() X(constX&) this=(X&) n_parents=1
use_template=3 interface-only
    pointer_to_this <pointer_type 0x7ffff6638000> reference_to_this
<reference_type 0x7ffff6638540> chain <type_decl 0x7ffff72011c8 allocator>>
$21 = void
(gdb) p rhstype->type_common.empty_flag
$22 = 0

that is set by
1972      /* Handle empty records as per the x86-64 psABI.  */
1973      TYPE_EMPTY_P (type) = targetm.calls.empty_record_p (type);

So I suppose relying on TYPE_EMPTY_P to silence false positives on empty
structures is not very portable.

Reply via email to