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: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to