Re: How to compile a C implementation of memcpy with gcc?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

On Sun, 28 Jul 2013, Rich Felker wrote:
>     Is there any reliable way, across GCC versions, to write memcpy in
>     pure C without having to worry that the compiler will translate it
>     into a function that calls itself?

Using "-ffreestanding" flag should be the way to achieve that.  The fact that
it does not have that effect is an extremely unfortunate bug in all recently
released versions of GCC.  I think it can be fixed, but I don't know how hard
that would be.  See comment 8 in PR 56888.

You can work around this bug by not using optimizations above -O2 and not
using structures, but I understand if you say that this is not a good
workaround.

I believe that people on freenode/#gcc who claimed that -ffreestanding should
not have such effect are in error.  Could you send me the chat log privately?

Also note that memset should also have this problem, not just memcpy.

Alexander




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux