Ping: https://gcc.gnu.org/pipermail/gcc-patches/2020-May/545856.html
On 5/15/20 5:31 PM, Martin Sebor wrote:
Besides better buffer overflow checking, the new GCC 10 attribute access also provides an opportunity to detect other kinds of bugs, including uninitialized accesses by user-defined functions. The attached patch implements this enhancement. In addition, the closely related PR 10138 requests that GCC warn when passing the address of an uninitialized variable to a const-qualified pointer function argument. Const pointers almost always imply a read access of the object, so the patch also enables the warning in these cases. (There are situations when a const pointer doesn't imply it and the warning takes care not to trigger overly enthusiastically.) Since pointers often point to allocated objects it seemed natural (and was surprisingly easy) to also detect uninitialized reads from those. For optimum results I slightly enhanced the detection of the referenced decls and allocations. In the process, I also noticed and fixed a small bug in the existing code. This helps both find more uninitialized variables and reduce the rate of false positives in existing warnings. Besides the usual GCC bootstrap/regtest I validated the changes by building a number of packages, including Binutils/GDB, Glibc, and the Linux kernel. It found a decent number of likely bugs (about half a doze by my count) but also triggered a few false positives. One class of such problems was due to the kernel's function __check_object_size (const void*, unsigned, bool) used to validate the sizes of objects without ever accessing them. To accommodate this idiom the patch adds a new mode to attribute access: none. Martin