public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/109995] New: Bogus warning about __builtin_memset, from -Wstringop-overflow
@ 2023-05-26 16:48 bruno at clisp dot org
  2023-05-26 16:51 ` [Bug middle-end/109995] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: bruno at clisp dot org @ 2023-05-26 16:48 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109995
           Summary: Bogus warning about __builtin_memset, from
                    -Wstringop-overflow
           Product: gcc
           Version: 13.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bruno at clisp dot org
  Target Milestone: ---

Created attachment 55171
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55171&action=edit
test case bar.c

In the attached program, -Wall produces a warning "warning: ‘__builtin_memset’
specified bound 18446744073709551614 exceeds maximum object size
9223372036854775807 [-Wstringop-overflow=]", in a function that does not invoke
'memset' nor '__builtin_memset'.

With gcc 10.4.0:
$ gcc -O2 -Wall -S bar.c
In function ‘memset_small’,
    inlined from ‘wrap’ at bar.c:242:1:
bar.c:249:17: warning: ‘__builtin_memset’ specified bound 18446744073709551614
exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
  249 |         do *++p = c; while (--n > 0);
      |            ~~~~~^~~

With gcc 11.3.0, 12.3.0, 13.1.0:
$ gcc -O2 -Wall -S bar.c
In function ‘memset_small’,
    inlined from ‘memset_small’ at bar.c:242:1,
    inlined from ‘wrap’ at bar.c:590:19:
bar.c:249:17: warning: ‘__builtin_memset’ specified bound 18446744073709551614
exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
  249 |         do *++p = c; while (--n > 0);
      |            ~~~~~^~~

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

* [Bug middle-end/109995] Bogus warning about __builtin_memset, from -Wstringop-overflow
  2023-05-26 16:48 [Bug middle-end/109995] New: Bogus warning about __builtin_memset, from -Wstringop-overflow bruno at clisp dot org
@ 2023-05-26 16:51 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-26 16:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
do *++p = c; while (--n > 0);

is turned into memset during optimizations.

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

end of thread, other threads:[~2023-05-26 16:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-26 16:48 [Bug middle-end/109995] New: Bogus warning about __builtin_memset, from -Wstringop-overflow bruno at clisp dot org
2023-05-26 16:51 ` [Bug middle-end/109995] " 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).