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

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Sat May 30 01:34:45 MSK 2020


Hi! Thanks for the review!

On 29/05/2020 08:24, Kirill Yukhin wrote:
> Hello,
> 
> On 28 май 01:32, Vladislav Shpilevoy wrote:
>> --- 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"
>>          )
> 
> So, you're disabling the warning for clang? According to comment it
> was disabled for GCC because of bug in it. Update comment? Enable for
> clang?

I disable it for clang, because invalid-offsetof is not only
about the thing mentioned in the GCC bug (va_list, which is a
part of struct fiber, which uses offsetof via rlist). It is a
warning about offsetof used on a non-POD type. We use plenty
of non-POD offsetof, every time when use rlist and some other
data structures. Both clang++ and g++ complain about it.

Here is what I get for clang++:

	tarantool/src/box/alter.cc:1148:2: error: offset of on non-standard-layout type 'typeof (*(op))' (aka 'AlterSpaceOp') [-Werror,-Winvalid-offsetof]
	        rlist_foreach_entry(op, &alter->ops, link)

I added a more descriptive comment:

====================
diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake
index ce3e7e506..9ad968d90 100644
--- a/cmake/compiler.cmake
+++ b/cmake/compiler.cmake
@@ -278,6 +278,11 @@ macro(enable_tnt_compile_flags)
 
     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"
         )


More information about the Tarantool-patches mailing list