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

--- Comment #7 from Jan Hubicka <hubicka at ucw dot cz> ---
> Yeah, and then maybe diagnose this "ODR violation".  Still

I think we do have this kinds of divergence (like glibcs
fortification), so I am not sure we want to warn by default.
> 
> __attribute__((__always_inline__)) void *memcpy();
> void *foo = memcpy;
> 
> should be ill-formed (but yeah, maybe this ship has sailed...).

Yep. We took wrong move calling alwys_inline always_inline at the time
it really meant disregard_inline_limits (that is correclty named
internally) and then giving it the semantics of really always inlining.
> 
> Now, I do wonder why during cgraph merging we prefer the non-definition
> declaration ... the code "works fine" if it's not memcpy but memcpyx
> (and thus not __builtin_memcpy but also memcpyx).

Hmm, we follow resolution file here and linker doesn't know about the
attributes.  I guess disabling merging here is something to do
(it was alwyas on my TODO list but not very high).  We eventualy ought
to also support keeping multiple inline bodies for different decls we
decide to not merge that is bit harder to get right.
> 
> I also wonder if we can get a better reduction of the kernel problem
> due to all the diagnostics I get:
> 
> 1.i:1:42: warning: 'always_inline' function might not be inlinable
> [-Wattribute]
>     1 | __attribute__((__always_inline__)) void *memcpy();
>       |                                          ^~~~~~
> 3.i:5:1: warning: conflicting types for built-in function 'memcpy'; expected
> 'void *(void *, const void *, long unsigned int)'
> [-Wbuiltin-declaration-mismatch]
>     5 | memcpy(void *dest, void *src, long len) {
>       | ^~~~~~
> 1.i:1:42: warning: type of 'memcpy' does not match original declaration
> [-Wlto-type-mismatch]
>     1 | __attribute__((__always_inline__)) void *memcpy();
>       |                                          ^

Hmm these warnings come from different places but indeed it is bit too
much :)

Honza

Reply via email to