Skip to content

Commit 70cbb4b

Browse files
tbaederrjoaosaffran
authored andcommitted
[clang][bytecode][NFC] Add failing memmove testcase (llvm#126682)
Reduced from libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/move.pass.cpp
1 parent bd033e7 commit 70cbb4b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

clang/test/AST/ByteCode/builtin-functions.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,6 +1272,22 @@ namespace BuiltinMemcpy {
12721272
return arr[0] * 1000 + arr[1] * 100 + arr[2] * 10 + arr[3];
12731273
}
12741274
static_assert(test_incomplete_array_type() == 1234); // both-error {{constant}} both-note {{in call}}
1275+
1276+
1277+
/// FIXME: memmove needs to support overlapping memory regions.
1278+
constexpr bool memmoveOverlapping() {
1279+
char s1[] {1, 2, 3};
1280+
__builtin_memmove(s1, s1 + 1, 2 * sizeof(char));
1281+
// Now: 2, 3, 3
1282+
bool Result1 = (s1[0] == 2 && s1[1] == 3 && s1[2]== 3);
1283+
1284+
__builtin_memmove(s1 + 1, s1, 2 * sizeof(char));
1285+
// Now: 2, 2, 3
1286+
bool Result2 = (s1[0] == 2 && s1[1] == 2 && s1[2]== 3);
1287+
1288+
return Result1 && Result2;
1289+
}
1290+
static_assert(memmoveOverlapping()); // expected-error {{failed}}
12751291
}
12761292

12771293
namespace Memcmp {

0 commit comments

Comments
 (0)