[Tarantool-patches] [PATCH v2 02/10] cmake: ignore warnings on alignof() and offsetof()

Timur Safin tsafin at tarantool.org
Thu May 28 23:18:34 MSK 2020


Nice, LGTM

: -----Original Message-----
: From: Vladislav Shpilevoy <v.shpilevoy at tarantool.org>
: Sent: Thursday, May 28, 2020 2:32 AM
: To: tarantool-patches at dev.tarantool.org; alyapunov at tarantool.org;
: korablev at tarantool.org; tsafin at tarantool.org
: Subject: [PATCH v2 02/10] cmake: ignore warnings on alignof() and
: offsetof()
: 
: Warning about invalid offsetof() (used on non-POD types) was set
: for g++, but wasn't for clang++.
: 
: Warning about invalid alignof() (when expression is passed to it
: instead of a type) wasn't ignored, but is going to be very
: useful in upcoming unaligned memory access patches. That allows
: to write something like:
: 
:     struct some_long_type *object = region_aligned_alloc(
:             region, size, alignof(*object));
: 
: This will work even if type of 'object' will change in future,
: and so it is safer. And shorter.
: 
: Part of #4609
: ---
:  cmake/compiler.cmake | 3 ++-
:  1 file changed, 2 insertions(+), 1 deletion(-)
: 
: diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake
: index 56429dc20..ce3e7e506 100644
: --- a/cmake/compiler.cmake
: +++ b/cmake/compiler.cmake
: @@ -276,11 +276,12 @@ macro(enable_tnt_compile_flags)
:          add_compile_flags("C;CXX" "-Wno-format-truncation")
:      endif()
: 
: -    if (CMAKE_COMPILER_IS_GNUCXX)
: +    if (CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCXX)
:          # G++ bug. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31488
:          add_compile_flags("CXX"
:              "-Wno-invalid-offsetof"
:          )
: +        add_compile_flags("C;CXX" "-Wno-gnu-alignof-expression")
:      endif()
: 
:      if (CMAKE_COMPILER_IS_GNUCC)
: --
: 2.21.1 (Apple Git-122.3)




More information about the Tarantool-patches mailing list