On 11/16/20 4:22 PM, Martin Sebor via Gcc-patches wrote: > The -Wmaybe-uninitialized enhancement to warn when the address > of an uninitialized object is passed to a function taking a const > pointer (or, in C++, a const reference) tries to avoid triggering > when the address is that of an empty object. It does that by > checking EMPTY_TYPE_P() and default_is_empty_record() for structs. > As it turns out, neither of these is reliable for this purpose > (both are subject to ABI constraints). > > The attached patch replaces these tests by one for is_empty_type(), > the workhorse function behind default_is_empty_record(). Besides > bootstrapping and regtesting on x86_64-linux I've tested the patch > works to suppress the warning with an aarch64-gnu-linux cross > (where the bogus warning was reported). > > Martin > > gcc-97840.diff > > PR middle-end/97840 - Bogus -Wmaybe-uninitialized passing an empty object to > a function > > gcc/ChangeLog: > * tree-ssa-uninit.c (maybe_warn_operand): Call is_empty_type. > * tree.c (default_is_empty_type): Rename... > (is_empty_type): ...to this. > * tree.h (is_empty_type): Declare.
OK jeff