COMP: sign check to avoid warnings about new[] range

This commit is contained in:
Mark Olesen
2021-04-26 17:07:41 +02:00
parent 86f627b9e6
commit 5a5fd1a43c
8 changed files with 31 additions and 11 deletions

View File

@ -50,6 +50,7 @@ void Foam::List<T>::doResize(const label newSize)
{
if (newSize > 0)
{
// With sign-check to avoid spurious -Walloc-size-larger-than
T* nv = new T[newSize];
const label overlap = min(this->size_, newSize);

View File

@ -31,8 +31,9 @@ License
template<class T>
inline void Foam::List<T>::doAlloc()
{
if (this->size_)
if (this->size_ > 0)
{
// With sign-check to avoid spurious -Walloc-size-larger-than
this->v_ = new T[this->size_];
}
}

View File

@ -35,8 +35,9 @@ inline void Foam::Matrix<Form, Type>::doAlloc()
{
const label len = size();
if (len)
if (len > 0)
{
// With sign-check to avoid spurious -Walloc-size-larger-than
v_ = new Type[len];
}
}