public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug analyzer/108616] New: -Wanalyzer-allocation-size false negatives for use of "alloca"
@ 2023-01-31 17:09 dmalcolm at gcc dot gnu.org
  2023-01-31 17:10 ` [Bug analyzer/108616] " dmalcolm at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2023-01-31 17:09 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108616
           Summary: -Wanalyzer-allocation-size false negatives for use of
                    "alloca"
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: dmalcolm at gcc dot gnu.org
  Target Milestone: ---

Consider e.g. this bogusly-sized alloca:

#include <alloca.h>
#include <stdint.h>

int main(void)
{
    int length = 99;

    int32_t *arr = alloca(length);

   return 0;
}

No warning is emitted for -Wanalyzer-allocation-size with -fanalyzer:
  https://godbolt.org/z/eTjf6fTzE
unless we use -Wsystem-headers:
  https://godbolt.org/z/oTKnG78ob

due to alloca being a macro inside a system header to __builtin_alloca.

We ought to warn for such cases; I have a fix under construction

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug analyzer/108616] -Wanalyzer-allocation-size false negatives for use of "alloca"
  2023-01-31 17:09 [Bug analyzer/108616] New: -Wanalyzer-allocation-size false negatives for use of "alloca" dmalcolm at gcc dot gnu.org
@ 2023-01-31 17:10 ` dmalcolm at gcc dot gnu.org
  2023-02-01  2:22 ` cvs-commit at gcc dot gnu.org
  2023-02-01  2:30 ` dmalcolm at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2023-01-31 17:10 UTC (permalink / raw)
  To: gcc-bugs

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

David Malcolm <dmalcolm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2023-01-31

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug analyzer/108616] -Wanalyzer-allocation-size false negatives for use of "alloca"
  2023-01-31 17:09 [Bug analyzer/108616] New: -Wanalyzer-allocation-size false negatives for use of "alloca" dmalcolm at gcc dot gnu.org
  2023-01-31 17:10 ` [Bug analyzer/108616] " dmalcolm at gcc dot gnu.org
@ 2023-02-01  2:22 ` cvs-commit at gcc dot gnu.org
  2023-02-01  2:30 ` dmalcolm at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-02-01  2:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by David Malcolm <dmalcolm@gcc.gnu.org>:

https://gcc.gnu.org/g:70d34f2a30a5f1a2a09f547d92243db32d79f3f7

commit r13-5614-g70d34f2a30a5f1a2a09f547d92243db32d79f3f7
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Tue Jan 31 21:18:10 2023 -0500

    analyzer: fix -Wanalyzer-allocation-size false -ve on alloca [PR108616]

    gcc/analyzer/ChangeLog:
            PR analyzer/108616
            * pending-diagnostic.cc (fixup_location_in_macro_p): Add "alloca"
            to macros that we shouldn't unwind inside.

    gcc/testsuite/ChangeLog:
            PR analyzer/108616
            * gcc.dg/analyzer/allocation-size-multiline-3.c: New test.
            * gcc.dg/analyzer/test-alloca.h: New test.

    Signed-off-by: David Malcolm <dmalcolm@redhat.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug analyzer/108616] -Wanalyzer-allocation-size false negatives for use of "alloca"
  2023-01-31 17:09 [Bug analyzer/108616] New: -Wanalyzer-allocation-size false negatives for use of "alloca" dmalcolm at gcc dot gnu.org
  2023-01-31 17:10 ` [Bug analyzer/108616] " dmalcolm at gcc dot gnu.org
  2023-02-01  2:22 ` cvs-commit at gcc dot gnu.org
@ 2023-02-01  2:30 ` dmalcolm at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2023-02-01  2:30 UTC (permalink / raw)
  To: gcc-bugs

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

David Malcolm <dmalcolm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #2 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Should be fixed by the above patch.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-02-01  2:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-31 17:09 [Bug analyzer/108616] New: -Wanalyzer-allocation-size false negatives for use of "alloca" dmalcolm at gcc dot gnu.org
2023-01-31 17:10 ` [Bug analyzer/108616] " dmalcolm at gcc dot gnu.org
2023-02-01  2:22 ` cvs-commit at gcc dot gnu.org
2023-02-01  2:30 ` dmalcolm at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).