Address GCC8 warning

The bootstrapping allocator needs to perform a memcpy to bypass the
removed move constructors on std::atomic.  This is safe as there is no
concurrency at this point, but GCC is unhappy with this.

This commit moves CI to GCC8 and disables this warning for that line.
This commit is contained in:
Matthew Parkinson
2020-02-29 08:59:02 +00:00
parent d74976de26
commit b756ca08a7
3 changed files with 23 additions and 8 deletions

View File

@@ -18,6 +18,12 @@
# define SNMALLOC_PURE __attribute__((const))
#endif
#if !defined(__clang__) && defined(__GNUC__)
# if __GNUC__ >= 8
# define GCC_VERSION_EIGHT_PLUS
# endif
#endif
#ifndef __has_builtin
# define __has_builtin(x) 0
#endif

View File

@@ -102,9 +102,18 @@ namespace snmalloc
MemoryProviderStateMixin<PAL>* allocated =
local.alloc_chunk<MemoryProviderStateMixin<PAL>, 1>();
#ifdef GCC_VERSION_EIGHT_PLUS
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
// Put temporary allocator we have used, into the permanent storage.
// memcpy is safe as this is entirely single threaded.
// memcpy is safe as this is entirely single threaded: the move
// constructors were removed as unsafe to move std::atomic in a
// concurrent setting.
memcpy(allocated, &local, sizeof(MemoryProviderStateMixin<PAL>));
#ifdef GCC_VERSION_EIGHT_PLUS
# pragma GCC diagnostic pop
#endif
return allocated;
}