Skip to content

Commit f831ff9

Browse files
rouaultLuckyRu
authored andcommitted
include/flatbuffers/base.h: fix no_sanitize issue with old clang (google#5610)
Older clang versions raise: ``` ./flatbuffers/base.h:365:1: error: unknown attribute 'no_sanitize' ignored [-Werror,-Wattributes] __supress_ubsan__("alignment") ^ ./flatbuffers/base.h:246:50: note: expanded from macro '__supress_ubsan__' #define __supress_ubsan__(type) __attribute__((no_sanitize(type))) ^ ``` Comparing https://releases.llvm.org/3.6.0/tools/clang/docs/AttributeReference.html with https://releases.llvm.org/3.7.0/tools/clang/docs/AttributeReference.html shows that __attribute__((no_sanitize(type))) is available since 3.7.0
1 parent ac0dbfd commit f831ff9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/flatbuffers/base.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ namespace flatbuffers {
242242
// Suppress Undefined Behavior Sanitizer (recoverable only). Usage:
243243
// - __supress_ubsan__("undefined")
244244
// - __supress_ubsan__("signed-integer-overflow")
245-
#if defined(__clang__)
245+
#if defined(__clang__) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >=7))
246246
#define __supress_ubsan__(type) __attribute__((no_sanitize(type)))
247247
#elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 409)
248248
#define __supress_ubsan__(type) __attribute__((no_sanitize_undefined))

0 commit comments

Comments
 (0)