From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp58.i.mail.ru (smtp58.i.mail.ru [217.69.128.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 66C0F4696C1 for ; Thu, 21 May 2020 23:37:38 +0300 (MSK) From: Vladislav Shpilevoy Date: Thu, 21 May 2020 22:37:25 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 02/10] cmake: ignore warnings on alignof() and offsetof() List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tarantool-patches@dev.tarantool.org, korablev@tarantool.org, tsafin@tarantool.org, alyapunov@tarantool.org, gorcunov@gmail.com 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)