https://llvm.org/bugs/show_bug.cgi?id=31178
Bug ID: 31178 Summary: Can't test for __builtin_offsetof Product: clang Version: 3.9 Hardware: PC OS: All Status: NEW Severity: normal Priority: P Component: C++ Assignee: unassignedclangb...@nondot.org Reporter: sits...@yahoo.com CC: dgre...@apple.com, llvm-bugs@lists.llvm.org Classification: Unclassified Description of the problem: It's not possible to test for __builtin_offsetof using __has_builtin. Steps to reproduce: 1. Create check_offsetof.c: #include <stdio.h> #include <stddef.h> #ifndef __has_builtin // Optional of course. #define __has_builtin(x) 0 // Compatibility with non-clang compilers. #endif struct my_struct { long long a; int b; }; int main(void) { #if __has_builtin(__builtin_offsetof) printf("Has __builtin_offsetof\n"); #else printf("Does NOT have __builtin_offsetof\n"); #endif printf("__builtin_offsetof(struct my_struct, b): %lu\n", __builtin_offsetof(struct my_struct, b)); return 0; } 2. Compile with clang check_offsetof.c -o check_offsetof 3. Run ./check_offsetof Expected result: Compilation error at 2 or output like Has __builtin_offsetof __builtin_offsetof(struct my_struct, b): 8 Actual result: Output like Does NOT have __builtin_offsetof __builtin_offsetof(struct my_struct, b): 8 Additional information: http://clang.llvm.org/docs/LanguageExtensions.html#has-builtin suggests it should be possible to use __has_builtin to test for a builtin and this works for things like __builtin_trap just not __builtin_offsetof. Version information: clang version 3.9.0 (branches/release_39 280336) Target: x86_64-unknown-linux-gnu -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs