File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -102,7 +102,9 @@ static int print_int(int n, char *p);
102102static int print_long (long n , char * p );
103103
104104
105- #if defined(__i386__ ) || defined(__x86_64__ ) || defined(_M_IX86 ) || defined(_M_X64 )
105+ /* The UBSan will warn about storing to misaligned address. */
106+ #if !(defined(__has_feature ) && __has_feature (undefined_behavior_sanitizer )) && \
107+ (defined(__i386__ ) || defined(__x86_64__ ) || defined(_M_IX86 ) || defined(_M_X64 ))
106108#define __print_unaligned_copy_16 (p , q ) (*(uint16_t*)(p) = *(uint16_t*)(q))
107109#else
108110#define __print_unaligned_copy_16 (p , q ) \
Original file line number Diff line number Diff line change @@ -28,7 +28,10 @@ extern "C" {
2828
2929#ifndef PORTABLE_UNALIGNED_ACCESS
3030
31- #if defined(__i386__ ) || defined(__x86_64__ ) || defined(_M_IX86 ) || defined(_M_X64 )
31+ #if defined(__has_feature ) && __has_feature (undefined_behavior_sanitizer )
32+ /* The UBSan will warn about unaligned access. */
33+ #define PORTABLE_UNALIGNED_ACCESS 0
34+ #elif defined(__i386__ ) || defined(__x86_64__ ) || defined(_M_IX86 ) || defined(_M_X64 )
3235#define PORTABLE_UNALIGNED_ACCESS 1
3336#else
3437#define PORTABLE_UNALIGNED_ACCESS 0
You can’t perform that action at this time.
0 commit comments