This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/55949] __builtin_object_size size passed to memcpy_chk is incorrect
- From: "jakub at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 11 Jan 2013 22:14:09 +0000
- Subject: [Bug tree-optimization/55949] __builtin_object_size size passed to memcpy_chk is incorrect
- Auto-submitted: auto-generated
- References: <bug-55949-4@http.gcc.gnu.org/bugzilla/>
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));
}