libobs: Calm stringop-overflow warning on GCC

Those warnings appeared with GCC 12 with -O2, those are potentially
created by regression from GCC.
This commit is contained in:
tytan652 2022-07-28 11:09:00 +02:00 committed by Ryan Foster
parent c648222332
commit 678b0287e6
2 changed files with 9 additions and 0 deletions

View file

@ -55,20 +55,25 @@
#define PRAGMA_WARN_PUSH __pragma(warning(push))
#define PRAGMA_WARN_POP __pragma(warning(pop))
#define PRAGMA_WARN_DEPRECATION
#define PRAGMA_WARN_STRINGOP_OVERFLOW
#elif defined(__clang__)
#define PRAGMA_WARN_PUSH _Pragma("clang diagnostic push")
#define PRAGMA_WARN_POP _Pragma("clang diagnostic pop")
#define PRAGMA_WARN_DEPRECATION \
_Pragma("clang diagnostic warning \"-Wdeprecated-declarations\"")
#define PRAGMA_WARN_STRINGOP_OVERFLOW
#elif defined(__GNUC__)
#define PRAGMA_WARN_PUSH _Pragma("GCC diagnostic push")
#define PRAGMA_WARN_POP _Pragma("GCC diagnostic pop")
#define PRAGMA_WARN_DEPRECATION \
_Pragma("GCC diagnostic warning \"-Wdeprecated-declarations\"")
#define PRAGMA_WARN_STRINGOP_OVERFLOW \
_Pragma("GCC diagnostic warning \"-Wstringop-overflow\"")
#else
#define PRAGMA_WARN_PUSH
#define PRAGMA_WARN_POP
#define PRAGMA_WARN_DEPRECATION
#define PRAGMA_WARN_STRINGOP_OVERFLOW
#endif
#include <stddef.h>

View file

@ -207,7 +207,11 @@ static inline void *darray_push_back_new(const size_t element_size,
darray_ensure_capacity(element_size, dst, ++dst->num);
last = darray_end(element_size, dst);
PRAGMA_WARN_PUSH
// NOTE: Those warning could be false positive from GCC 12 with -O2
PRAGMA_WARN_STRINGOP_OVERFLOW
memset(last, 0, element_size);
PRAGMA_WARN_POP
return last;
}