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

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Jan Hubicka from comment #5)
> > Btw, one solution would be to drop __always_inline__ after always-inline
> > inlining
> > and thus make it reliably not present for IPA inlining.
> Removing it would make you to lose those errors, but we can ignore it
> for late inlining if we decide we do not really care about always
> inlining indirect calls (that are not reliably inlined by early
> inliner).
> 
> But I tried that at some point and broke kernel.
> 
> Note that we could also use syntactic aliase and consider two decls
> unmergeable if they differ by always_inline attribute.  That should make
> it to behave consistently...

Yeah, and then maybe diagnose this "ODR violation".  Still

__attribute__((__always_inline__)) void *memcpy();
void *foo = memcpy;

should be ill-formed (but yeah, maybe this ship has sailed...).

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).

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();
      |                                          ^

...

Reply via email to