This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/55949] __builtin_object_size size passed to memcpy_chk is incorrect


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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> 2013-01-11 22:14:09 UTC ---
Looks like a bug in whatever <string.h> headers you are using.
The second parameter for __builtin_object_size for memcpy should be always 0,
not __USE_FORTIFY_LEVEL > 1 (that is used for functions like strcpy and has the
additional restriction that the copying isn't allowed to cross array/field
boundaries).
In glibc there is
#define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)
#define __bos0(ptr) __builtin_object_size (ptr, 0)
and
__extern_always_inline void *
__NTH (memcpy (void *__restrict __dest, __const void *__restrict __src,
               size_t __len))
{
  return __builtin___memcpy_chk (__dest, __src, __len, __bos0 (__dest));
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]