http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56888

             Bug #: 56888
           Summary: memcpy implementation optimized as a call to memcpy
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: xanc...@gmail.com


Created attachment 29833
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29833
Naive memcpy implementation

Compiling the attached trivial memcpy implementation with -O3 -ffreestanding
-fno-builtin -nodefaultlibs -nostdlib yields a memcpy which calls itself.
Although the man page explicitly supports this behavior (“The compiler may
generate calls to "memcmp", "memset", "memcpy" and "memmove".”), I find it hard
to write a working compiler-optimized memcpy under these circumstances.
Using -O2 instead of -O3 “fixes” this.

Everything worked for me up until GCC 4.7.3, I'm using Arch Linux, my GCC has
been configured with: /build/src/gcc-4.8.0/configure --prefix=/usr
--libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared
--enable-threads=posix --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch
--enable-gnu-unique-object --enable-linker-build-id --enable-cloog-backend=isl
--disable-cloog-version-check --enable-lto --enable-gold --enable-ld=default
--enable-plugin --with-plugin-ld=ld.gold --with-linker-hash-style=gnu
--disable-install-libiberty --enable-multilib --disable-libssp --disable-werror
--enable-checking=release.

Reply via email to