[clang][Interp] Reject dummy pointers from __builtin_strcmp()
We can't load anything from them, so reject them here.
This commit is contained in:
parent
a30ba2ca21
commit
b901b0d3ed
@ -132,6 +132,9 @@ static bool interp__builtin_strcmp(InterpState &S, CodePtr OpPC,
|
||||
if (!CheckLive(S, OpPC, A, AK_Read) || !CheckLive(S, OpPC, B, AK_Read))
|
||||
return false;
|
||||
|
||||
if (A.isDummy() || B.isDummy())
|
||||
return false;
|
||||
|
||||
assert(A.getFieldDesc()->isPrimitiveArray());
|
||||
assert(B.getFieldDesc()->isPrimitiveArray());
|
||||
|
||||
|
@ -34,6 +34,14 @@ namespace strcmp {
|
||||
static_assert(__builtin_strcmp(kFoobar, kFoobazfoobar + 6) == 0, ""); // both-error {{not an integral constant}} \
|
||||
// both-note {{dereferenced one-past-the-end}} \
|
||||
// expected-note {{in call to}}
|
||||
|
||||
/// Used to assert because we're passing a dummy pointer to
|
||||
/// __builtin_strcmp() when evaluating the return statement.
|
||||
constexpr bool char_memchr_mutable() {
|
||||
char buffer[] = "mutable";
|
||||
return __builtin_strcmp(buffer, "mutable") == 0;
|
||||
}
|
||||
static_assert(char_memchr_mutable(), "");
|
||||
}
|
||||
|
||||
/// Copied from constant-expression-cxx11.cpp
|
||||
|
Loading…
x
Reference in New Issue
Block a user