https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97840
--- Comment #5 from Martin Sebor <msebor at gcc dot gnu.org> ---
The warning code considers more that just TYPE_EMPTY_P():
/* Avoid warning about empty types such as structs with no members.
The first_field() test is important for C++ where the predicate
alone isn't always sufficient. */
tree rhstype = TREE_TYPE (rhs);
if (POINTER_TYPE_P (rhstype))
rhstype = TREE_TYPE (rhstype);
if (TYPE_EMPTY_P (rhstype)
|| (RECORD_OR_UNION_TYPE_P (rhstype)
&& (!first_field (rhstype)
|| default_is_empty_record (rhstype))))
return NULL_TREE;
If the struct has no data members the warning shouldn't trigger even if
TYPE_EMPTY_P() is false. I don't think std::allocator has data members so we
need to see why the check isn't good enough. Ah, it looks like the whole
condition is false because default_is_empty_record (rhstype) is false, which is
because TREE_ADDRESSABLE (rhstype) is true. Is that what has changed with your
patch? Either way, I do agree that the warning shouldn't be sensitve to ABI
nuances so perhaps default_is_empty_type() (rhstype) would be a better API to
use here (except it's static). Let me look into that.