Skip to content

Commit

Permalink
Avoid newer clang warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
aslze committed Feb 19, 2025
1 parent 1fa09cc commit f37393d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
13 changes: 9 additions & 4 deletions include/asl/Array.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
#pragma warning(disable : 4251)
#pragma warning(push)
#pragma warning(disable : 4284 26451)
#else
#pragma GCC diagnostic push
//#pragma GCC diagnostic ignored "-Wnontrivial-memcall"
#endif

namespace asl {
Expand Down Expand Up @@ -401,7 +404,7 @@ class Array
if (i + n > m)
return *this;
asl_destroy(_a+i, n);
memmove(_a+i, _a+i+n, (m-i-n)*sizeof(T));
memmove((char*)(_a + i), _a + i + n, (m - i - n)*sizeof(T));
d().n -= n;
resize(m - n);
return *this;
Expand Down Expand Up @@ -590,7 +593,7 @@ class Array
n--;
}
else
memcpy(&_a[j++], &_a[i], sizeof(T));
memcpy((char*)&_a[j++], &_a[i], sizeof(T));
d().n = n;
return *this;
}
Expand Down Expand Up @@ -633,7 +636,7 @@ Array<T>& Array<T>::reserve(int m)
ASL_BAD_ALLOC();
b = (T*) ( p + sizeof(Data) );
int i = min(m,n), j = sizeof(T), k = i*j;
memcpy(b, _a, k);
memcpy((char*)b, _a, k);
}
else if(s1 != s)
{
Expand Down Expand Up @@ -684,7 +687,7 @@ Array<T>& Array<T>::insert(int k, const T& x)
h->s=s1;
}
if (k < n) {
memmove((char*)_a + (k + 1) * sizeof(T), (void*)(_a + k), (n - k) * sizeof(T));
memmove((char*)(_a + k + 1), (char*)(_a + k), (n - k) * sizeof(T));
}
asl_construct_copy(_a + k, x);
h->n = n+1;
Expand Down Expand Up @@ -836,6 +839,8 @@ static asl::Array<T> rad2deg(const asl::Array<T>& a)
}
#ifdef _MSC_VER
#pragma warning(pop)
#else
#pragma GCC diagnostic pop
#endif

#endif
4 changes: 2 additions & 2 deletions include/asl/Var.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,13 @@ class ASL_API Var
Var(Type t);
Var(const Var& v)
{
memcpy(this, &v, sizeof(v));
memcpy((byte*)this, &v, sizeof(v));
if(!isPod())
copy(v);
}
void copy(const Var& v);
#ifdef ASL_HAVE_MOVE
Var(Var&& v) {memcpy(this, &v, sizeof(Var)); v._type = NONE;}
Var(Var&& v) {memcpy((byte*)this, &v, sizeof(Var)); v._type = NONE;}
void operator=(Var&& v) {bswap(*this, v);}
#endif
#ifdef ASL_HAVE_INITLIST
Expand Down
4 changes: 2 additions & 2 deletions include/asl/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ inline void bswap(T& a, T& b)
{
char t[sizeof(T)];
memcpy(t, &a, sizeof(T));
memcpy(&a, &b, sizeof(T));
memcpy(&b, t, sizeof(T));
memcpy((char*)&a, &b, sizeof(T));
memcpy((char*)&b, t, sizeof(T));
}


Expand Down
2 changes: 1 addition & 1 deletion src/Var.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ void Var::operator=(const Var& v)

if(!isPod())
free();
memcpy(this, &v, sizeof(v));
memcpy((byte*)this, &v, sizeof(v));
switch(_type)
{
case STRING:
Expand Down

0 comments on commit f37393d

Please sign in to comment.