public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/101455] New: missing -Wstringop-overflow on buffer overflow by a complex number
@ 2021-07-14 17:43 msebor at gcc dot gnu.org
  2021-08-28 20:53 ` [Bug middle-end/101455] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-07-14 17:43 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101455
           Summary: missing -Wstringop-overflow on buffer overflow by a
                    complex number
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

The store in the function below overflows the buffer and should be diagnosed by
-Wstringop-overflow (which is enabled by default) but isn't.  It's only
diagnosed by -Warray-bounds (which is included in -Wall).

$ cat a.c && gcc -O2 -S -fdump-tree-strlen=/dev/stdout a.c
void* f (double x, double i)
{
  _Complex double *p = __builtin_malloc (sizeof (double));
  *p = __builtin_complex (x, i);
  return p;
}

;; Function f (f, funcdef_no=0, decl_uid=1944, cgraph_uid=1, symbol_order=0)

;; 1 loops found
;;
;; Loop 0
;;  header 0, latch 1
;;  depth 0, outer -1
;;  nodes: 0 1 2
;; 2 succs { 1 }
void * f (double x, double i)
{
  complex double * p;

  <bb 2> [local count: 1073741824]:
  p_3 = __builtin_malloc (8);
  REALPART_EXPR <*p_3> = x_4(D);
  IMAGPART_EXPR <*p_3> = i_5(D);
  return p_3;

}

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

* [Bug middle-end/101455] missing -Wstringop-overflow on buffer overflow by a complex number
  2021-07-14 17:43 [Bug middle-end/101455] New: missing -Wstringop-overflow on buffer overflow by a complex number msebor at gcc dot gnu.org
@ 2021-08-28 20:53 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-28 20:53 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-08-28
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed, that is we should get a warning at -O0 -W -Wall.

Note the gimple is different between -O2 and -O0.

-O0 gimple:
  p_4 = __builtin_malloc (8);
  _1 = COMPLEX_EXPR <x_5(D), i_6(D)>;
  *p_4 = _1;

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

end of thread, other threads:[~2021-08-28 20:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-14 17:43 [Bug middle-end/101455] New: missing -Wstringop-overflow on buffer overflow by a complex number msebor at gcc dot gnu.org
2021-08-28 20:53 ` [Bug middle-end/101455] " 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).