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

Martin Sebor <msebor at gcc dot gnu.org> changed:

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

--- Comment #8 from Martin Sebor <msebor at gcc dot gnu.org> ---
Zero allocations should be diagnosed by -Walloc-zero.  The option is disabled
by default to avoid false positives for calls to malloc(0) emitted by GCC in
some cases.  The test case in comment #0 isn't diagnosed even when -Walloc-zero
is explicitly set is a bug.  It should be diagnosed, and I think for VLAs the
warning should be enabled in -Wall to help detect potential aliasing
violations).

Some uses of zero length arrays that aren't VLAs are diagnosed by
-Wzero-length-bounds (enabled by -Warray-bounds).  I posted a patch in November
to enhance their detection, including VLAs, but it never got reviewed.  I
expect to resubmit it for GCC 12.  With that patch, the test case in comment #0
is diagnosed as long as the array is either accessed or passed as an argument
to a function that might use it.

Reply via email to