Skip to content

Commit

Permalink
Ticket 12966 added regression test (#6662)
Browse files Browse the repository at this point in the history
  • Loading branch information
orbitcowboy authored Aug 6, 2024
1 parent 775e3d9 commit 4b2d5b3
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions test/cfg/std.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4870,11 +4870,12 @@ void string_substr(std::string s)
s.substr(1, 3);
}

void stdspan()
{
#ifndef __cpp_lib_span
#warning "This compiler does not support std::span"
#else
void stdspan()
{

std::vector<int> vec{1,2,3,4};
std::span spn{vec};
// cppcheck-suppress unreadVariable
Expand Down Expand Up @@ -4914,9 +4915,19 @@ void stdspan()
spn3.first<1>();
spn3.last<1>();
spn3.subspan<1, 1>();
#endif
}

std::span<const int> returnDanglingLifetime_std_span0() {
static int a[10]{};
return a;
}

std::span<const int> returnDanglingLifetime_std_span1() {
static std::vector<int> v;
return v;
}
#endif

void beginEnd()
{
std::vector<int> v;
Expand Down Expand Up @@ -4980,9 +4991,9 @@ void smartPtr_get2(std::vector<std::unique_ptr<int>>& v)
}

bool smartPtr_get3(size_t n, size_t i) { // #12748
std::unique_ptr<int[]> buf = std::make_unique<int[]>(n);
const int* p = buf.get() + i;
return p != nullptr;
std::unique_ptr<int[]> buf = std::make_unique<int[]>(n);
const int* p = buf.get() + i;
return p != nullptr;
}

void smartPtr_reset()
Expand Down Expand Up @@ -5094,7 +5105,7 @@ std::vector<int> containerOutOfBounds_push_back() { // #12775
return v;
}

template <typename T>
template<typename T>
void constVariablePointer_push_back(std::vector<T*>& d, const std::vector<T*>& s) {
for (const auto& e : s) {
T* newE = new T(*e);
Expand Down

0 comments on commit 4b2d5b3

Please sign in to comment.