File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
stdlib/public/SwiftShims/swift/shims
validation-test/ClangImporter Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -60,8 +60,11 @@ static inline __swift_size_t _swift_stdlib_strlen_unsigned(const unsigned char *
60
60
SWIFT_READONLY
61
61
static inline int _swift_stdlib_memcmp (const void *s1, const void *s2,
62
62
__swift_size_t n) {
63
+ #if defined(__APPLE__)
64
+ // Darwin defines memcmp with optional pointers, preserve the same type here.
65
+ extern int memcmp (const void * _Nullable, const void * _Nullable, __swift_size_t );
63
66
// FIXME: Is there a way to identify Glibc specifically?
64
- #if (defined(__gnu_linux__) || defined(__ANDROID__)) && !defined(__musl__)
67
+ #elif (defined(__gnu_linux__) || defined(__ANDROID__)) && !defined(__musl__)
65
68
extern int memcmp (const void * _Nonnull, const void * _Nonnull, __swift_size_t );
66
69
#else
67
70
extern int memcmp (const void * _Null_unspecified, const void * _Null_unspecified, __swift_size_t );
Original file line number Diff line number Diff line change 1
- /// rdar://69876253
1
+ /// Darwin's memcmp accepts nullable pointers, make sure the SwiftShims one
2
+ /// preserves the same type.
2
3
// REQUIRES: VENDOR=apple
3
4
// RUN: %target-build-swift %s -o %t.out
4
5
@@ -9,4 +10,6 @@ func foo () {
9
10
let a = UnsafeMutableRawPointer . allocate ( byteCount: 4 , alignment: 4 )
10
11
let b = UnsafeMutableRawPointer . allocate ( byteCount: 4 , alignment: 4 )
11
12
memcmp ( a, b, 4 )
13
+
14
+ memcmp ( nil , nil , 0 )
12
15
}
You can’t perform that action at this time.
0 commit comments