public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug analyzer/115380] New: Missing MUL_OVERFLOW support in analayzer
@ 2024-06-07  2:09 pinskia at gcc dot gnu.org
  0 siblings, 0 replies; only message in thread
From: pinskia at gcc dot gnu.org @ 2024-06-07  2:09 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 115380
           Summary: Missing MUL_OVERFLOW support in analayzer
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
            Blocks: 109896
  Target Milestone: ---

Take (which is a modified version of g++.dg/analyzer/placement-new-size.C):
```
/* { dg-additional-options "-Wno-placement-new
-Wno-analyzer-use-of-uninitialized-value" } */

#include <new>
#include <stdlib.h>
#include <stdint.h>

void static_buffer_too_short (int t)
{
  int n = t*4;
  int n1 = (t+1);
  if (__builtin_mul_overflow(n1, 4, &n1))
    __builtin_abort();
  char buf[n];
  char *p = new (buf) char[n1]; /* { dg-warning "stack-based buffer overflow" }
*/
}

void static_buffer_too_short1 (int t)
{
  int n = t*4;
  int n1 = (t+1);
  n1 = n1*4;
  char buf[n];
  char *p = new (buf) char[n1]; /* { dg-warning "stack-based buffer overflow" }
*/
}

```
static_buffer_too_short should warn the same way as static_buffer_too_short1
currently does.

Note this was found while looking into the regressions developing of the patch
for PR 109896.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109896
[Bug 109896] Missed optimisation: overflow detection in multiplication
instructions for operator new

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-06-07  2:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-07  2:09 [Bug analyzer/115380] New: Missing MUL_OVERFLOW support in analayzer pinskia 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).