[PATCH] use is_empty_type to check for empty types (PR 97840)

Martin Sebor msebor@gmail.com
Mon Nov 16 23:22:49 GMT 2020


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcc-97840.diff
Type: text/x-patch
Size: 2629 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20201116/601c5376/attachment.bin>


More information about the Gcc-patches mailing list