[LLVMbugs] [Bug 23277] New: __builtin_object_size(null_pointer) returns the wrong result
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sat Apr 18 09:37:31 PDT 2015
https://llvm.org/bugs/show_bug.cgi?id=23277
Bug ID: 23277
Summary: __builtin_object_size(null_pointer) returns the wrong
result
Product: clang
Version: unspecified
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: danielmicay at gmail.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
This outputs (size_t)-1 in both cases with `gcc -O2` but clang gives 0 for the
second case:
#include <stdio.h>
int main(int argc, char **argv) {
printf("%zu\n", __builtin_object_size(NULL, 0));
void *p = NULL;
printf("%zu\n", __builtin_object_size(p, 0));
return 0;
}
This is broken with glibc's _FORTIFY_SOURCE implementation for nullable
parameters. It assumes that it can do comparisons like `object_size(buffer) <
copy_size` after handling the unknown case, but this can result in a false
positive with Clang. It's not a glibc bug because they're using GNU C as it is
defined by GCC, which is where this feature comes from.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150418/ada64f34/attachment.html>
More information about the llvm-bugs
mailing list