brintos

brintos / llvm-project-archived public Read only

0
0
Text · 808 B · 5f361c3 Raw
24 lines · cpp
1// RUN: %check_clang_tidy %s bugprone-not-null-terminated-result %t -- \2// RUN: -- -std=c++17 -I %S/Inputs/not-null-terminated-result3 4// This test case reproduces the crash when the check tries to evaluate5// a value-dependent expression using EvaluateAsInt() in6// bugprone-not-null-terminated-result, where the src parameter of memcpy is7// value-dependent, but the length is not.8 9// expected-no-diagnostics10 11#include "not-null-terminated-result-cxx.h"12 13template<size_t N>14class ValueDependentClass {15public:16  void copyData(char* Dst) {17    const char* Src = reinterpret_cast<const char*>(this);18    // The length parameter is arbitrary, but the crash is not reproduced if it is N.19    memcpy(Dst, Src, 32);20  }21};22 23template class ValueDependentClass<42>; // The template parameter value is arbitrary.24