https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102061
Bug ID: 102061
Summary: .constprop gets exposed in warning message
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: enhancement
Priority: P3
Component: ipa
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
CC: marxin at gcc dot gnu.org
Target Milestone: ---
Take:
static inline void
foo (char *p)
{
__builtin___memcpy_chk (p, "abc", 3, __builtin_object_size (p, 0));
}
static void
bar (char *p) __attribute__((noinline));
static void
bar (char *p)
{
foo (p);
}
void f(char*) __attribute__((noipa));
char buf[2];
void
baz (void) __attribute__((noinline));
void
baz (void)
{
bar (buf);
f(buf);
}
void f(char*)
{}
int main(void)
{
baz();
}
---- CUT ---
Compile the C program with "-O2 -Wall", we get:
In function 'foo',
inlined from 'bar.constprop' at <source>:12:3:
<source>:5:3: warning: '__builtin___memcpy_chk' forming offset 2 is out of the
bounds [0, 2] of object 'buf' with type 'char[2]' [-Warray-bounds]
5 | __builtin___memcpy_chk (p, "abc", 3, __builtin_object_size (p, 0));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>: In function 'bar.constprop':
<source>:15:6: note: 'buf' declared here
15 | char buf[2];
| ^~~
See how bar.constprop is exposed. That is an internal details.
Note compiling it with the C++ front-end we get:
inlined from 'void bar(char*)' at <source>:12:7:
And then compiling with -flto again we get the bar.constprop.
But really we should add another note saying where the clone was created from.