Skip to content

Commit

Permalink
Merge pull request #134 from microsoft/gcc8_warning
Browse files Browse the repository at this point in the history
Address GCC8 warning
  • Loading branch information
mjp41 authored Mar 3, 2020
2 parents 814f3ba + b756ca0 commit ef77bcc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
14 changes: 7 additions & 7 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ jobs:
SelfHost: false
CMakeArgs: ''

GCC-7 Debug:
CC: gcc-7
CXX: g++-7
GCC-8 Debug:
CC: gcc-8
CXX: g++-8
BuildType: Debug
SelfHost: false
CMakeArgs: ''

GCC-7 Release:
CC: gcc-7
CXX: g++-7
GCC-8 Release:
CC: gcc-8
CXX: g++-8
BuildType: Release
SelfHost: false
CMakeArgs: ''
Expand All @@ -57,7 +57,7 @@ jobs:
- script: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install -y ninja-build libc++-dev libc++abi-dev libc++abi1 libstdc++-7-dev gcc-7 g++-7
sudo apt-get install -y ninja-build libc++-dev libc++abi-dev libc++abi1 libstdc++-7-dev gcc-8 g++-8
# sudo apt-get install clang-6.0 clang++-6.0
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/$(CC) 100
Expand Down
6 changes: 6 additions & 0 deletions src/ds/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion src/mem/largealloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,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

// Register this allocator for low-memory call-backs
if constexpr (pal_supports<LowMemoryNotification, PAL>)
Expand Down

0 comments on commit ef77bcc

Please sign in to comment.