[LLVMbugs] [Bug 23093] New: clang -mkernel/-ffreestanding/-fno-builtin evaluates "__has_builtin(__builtin___memcpy_chk)" as true

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Mar 31 17:14:29 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=23093

            Bug ID: 23093
           Summary: clang -mkernel/-ffreestanding/-fno-builtin evaluates
                    "__has_builtin(__builtin___memcpy_chk)" as true
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ahmed.bougacha at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

__has_builtin currently disregards -mkernel/-ffreestanding/-fno-builtin for the
various __builtin_s.  I tried with __builtin_memcpy_chk and __builtin_expect,
and they're always marked as available.  

For the latter that's perfectly fine (as it is for most __builtin_s), but is it
also for the _chk functions?  We provide them as builtins, but they really are
functions, so perhaps an exception is acceptable.

One alternative would be to tell users to check for freestanding/kernel, but
that's a bit contrived when there's the more descriptive __has_builtin.



 $ cat builtin.c                                                               
                                                                               
                                                                               
                                                                               
     #if __has_builtin(__builtin___memcpy_chk)
#warning "__memcpy_chk is available"
#else
#warning "__memcpy_chk is not available"
#endif

 $ clang ./builtin.c -fsyntax-only -fno-builtin                                
                                                                               
                                                                               
                                                                              
./builtin.c:2:2: warning: "__memcpy_chk is available" [-W#warnings]
#warning "__memcpy_chk is available"
 ^
1 warning generated.

-- 
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/20150401/be94a84a/attachment.html>


More information about the llvm-bugs mailing list