public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ipa/96503] New: attribute alloc_size effect lost after inlining
@ 2020-08-06 15:51 msebor at gcc dot gnu.org
  2022-09-30  1:54 ` [Bug ipa/96503] " kees at outflux dot net
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: msebor at gcc dot gnu.org @ 2020-08-06 15:51 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96503
           Summary: attribute alloc_size effect lost after inlining
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ipa
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---

Similar to pr96502, the test case below shows that the effect of attribute
alloc_size on warnings is also lost after inlining.  I open this as a separate
bug (and expect to raise others) because I expect the "fixes" to be different
in each case.   Like pr96502, this also came up in the following discussion:
https://gcc.gnu.org/pipermail/gcc-patches/2020-August/551526.html

$ cat x.c && gcc -O2 -S -Wall -Wextra -fdump-tree-optimized=/dev/stdout x.c
int* f (int);

__attribute__ ((alloc_size (1), noinline)) int*
 f0 (int n) { return f (n); }

void h0 (void)
{
  int *p = f0 (3);
  __builtin_memset (p, 0, 3 * sizeof p);   // warning (good)
}

__attribute__ ((alloc_size (1))) int*
f1 (int n) { return f (n); }

void h1 (void)
{ 
  int *p = f1 (3);
  __builtin_memset (p, 0, 3 * sizeof p);   // missing warning
}

x.c: In function ‘h0’:
x.c:9:3: warning: ‘__builtin_memset’ forming offset [3, 23] is out of the
bounds [0, 3] [-Warray-bounds]
    9 |   __builtin_memset (p, 0, 3 * sizeof p);   // warning (good)
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

end of thread, other threads:[~2023-11-03 19:04 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-06 15:51 [Bug ipa/96503] New: attribute alloc_size effect lost after inlining msebor at gcc dot gnu.org
2022-09-30  1:54 ` [Bug ipa/96503] " kees at outflux dot net
2022-11-18 23:57 ` pageexec at gmail dot com
2023-10-25  5:46 ` muecker at gwdg dot de
2023-10-25  5:54 ` sjames at gcc dot gnu.org
2023-10-25 10:55 ` siddhesh at gcc dot gnu.org
2023-10-25 11:08 ` siddhesh at gcc dot gnu.org
2023-10-25 13:03 ` muecker at gwdg dot de
2023-10-25 13:40 ` siddhesh at gcc dot gnu.org
2023-11-03 19:04 ` uecker 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).