[LLVMbugs] [Bug 9426] New: change __builtin_object_size prototype
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Mar 8 07:12:03 PST 2011
http://llvm.org/bugs/show_bug.cgi?id=9426
Summary: change __builtin_object_size prototype
Product: clang
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: pageexec at freemail.hu
CC: llvmbugs at cs.uiuc.edu, pageexec at freemail.hu
Blocks: 4068
while gcc declares __builtin_object_size as
size_t __builtin_object_size (void * PTR, int TYPE)
it generates a warning in clang for 'const void *' PTR parameters (and
presumably for volatile ones too, although it's probably rare in practice, i
certainly didn't see it trigger in linux) when compiling linux:
arch/x86/include/asm/uaccess_32.h:241:11: warning: passing 'const void *' to
parameter of type 'void *' discards qualifiers
int sz = __compiletime_object_size(from);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler-gcc4.h:64:62: note: instantiated from:
#define __compiletime_object_size(obj) __builtin_object_size((obj), 0)
^~~~~
now one can fix this macro by adding an explicit (void *) cast for 'obj' but
i'd suggest to change the builtin's prototype in clang itself since this
builtin function really doesn't need a non-const pointer for its job:
--- llvm/tools/clang/include/clang/Basic/Builtins.def (revision 127235)
+++ llvm/tools/clang/include/clang/Basic/Builtins.def (working copy)
@@ -443,7 +443,7 @@
BUILTIN(__builtin_extend_pointer, "ULLiv*", "n") // _Unwind_Word == uint64_t
// GCC Object size checking builtins
-BUILTIN(__builtin_object_size, "zv*i", "n")
+BUILTIN(__builtin_object_size, "zvC*i", "n")
BUILTIN(__builtin___memcpy_chk, "v*v*vC*zz", "nF")
BUILTIN(__builtin___memmove_chk, "v*v*vC*zz", "nF")
BUILTIN(__builtin___mempcpy_chk, "v*v*vC*zz", "nF")
and perhaps add 'D' too for handling volatile pointers as well.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list