From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 0D128469719 for ; Fri, 11 Sep 2020 14:24:47 +0300 (MSK) Received: by mail-lj1-f194.google.com with SMTP id b19so12071558lji.11 for ; Fri, 11 Sep 2020 04:24:47 -0700 (PDT) From: Cyrill Gorcunov Date: Fri, 11 Sep 2020 14:24:29 +0300 Message-Id: <20200911112431.866554-2-gorcunov@gmail.com> In-Reply-To: <20200911112431.866554-1-gorcunov@gmail.com> References: <20200911112431.866554-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 1/3] cmake: ignore warnings on alignof() and offsetof() List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tml Cc: Vladislav Shpilevoy From: Vladislav Shpilevoy 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 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake index 56429dc20..b0908f3b3 100644 --- a/cmake/compiler.cmake +++ b/cmake/compiler.cmake @@ -276,11 +276,17 @@ 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 + # Also offsetof() is widely used in Tarantool source code + # for classes and structs to implement intrusive lists and + # some other data structures. G++ and clang++ both + # complain about classes, having a virtual table. They + # complain fair, but this can't be fixed for now. add_compile_flags("CXX" "-Wno-invalid-offsetof" ) + add_compile_flags("C;CXX" "-Wno-gnu-alignof-expression") endif() if (CMAKE_COMPILER_IS_GNUCC) -- 2.26.2