Fixed `std::vector::data` return type (#5116)

This caused many `arithOperationsOnVoidPointer` false positives in my project which uses `std::vector<uint8_t>` in many places.
This commit is contained in:
SChernykh 2023-06-05 20:47:42 +02:00 committed by GitHub
parent 34cecf2336
commit 93595aeff0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -6773,7 +6773,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<function name="std::array::data,std::vector::data,std::span::data">
<use-retval/>
<const/>
<returnValue type="void *"/>
<returnValue type="const T *"/>
<noreturn>false</noreturn>
</function>
<!-- https://en.cppreference.com/w/cpp/container/deque/swap -->

View File

@ -4739,4 +4739,11 @@ void smartPtr_release()
p.release();
//cppcheck-suppress nullPointer
*p = 1;
}
}
void std_vector_data_arithmetic()
{
std::vector<char> buf;
buf.resize(1);
memcpy(buf.data() + 0, "", 1);
}