From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id CE96B2B5E5 for ; Sat, 15 Sep 2018 02:07:13 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ubi2zAtIMWZL for ; Sat, 15 Sep 2018 02:07:13 -0400 (EDT) Received: from smtp62.i.mail.ru (smtp62.i.mail.ru [217.69.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 40B6F2906E for ; Sat, 15 Sep 2018 02:07:13 -0400 (EDT) From: Alexander Turenko Subject: [tarantool-patches] [PATCH] Fix Debug build on GCC 8 Date: Sat, 15 Sep 2018 09:07:05 +0300 Message-Id: <8c538963a78f22746233b22648fb2aa6933dc135.1536991382.git.alexander.turenko@tarantool.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: Kirill Yukhin Cc: Alexander Turenko , tarantool-patches@freelists.org, Konstantin Osipov Fixed false positive -Wimplicit-fallthrough in http_parser.c by adding a break. The code jumps anyway, so the execution flow is not changed. Fixed false positive -Wparenthesis in reflection.h by removing the parentheses. The argument 'method' of the macro 'type_foreach_method' is just name of the loop variable and is passed to the macro for readability reasons. Fixed false positive -Wcast-function-type triggered by reflection.h by adding -Wno-cast-function-type for sources and unit tests. We cast a pointer to a member function to an another pointer to member function to store it in a structure, but we cast it back before made a call. It is legal and does not lead to an undefined behaviour. Fixes #3685. --- issue: https://github.com/tarantool/tarantool/issues/3685 branch: https://github.com/tarantool/tarantool/tree/Totktonada/gh-3685-fix-debug-build-gcc-8 travis-ci: https://travis-ci.org/tarantool/tarantool/builds/428903995 Please, push it to 1.9 as Kostya O. suggests. src/CMakeLists.txt | 8 ++++++++ src/http_parser.c | 1 + src/reflection.h | 6 +++--- test/unit/CMakeLists.txt | 8 ++++++++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b1c4cd711..2e7e1c436 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,6 +3,14 @@ # enable_tnt_compile_flags() +# Suppress noise GCC 8 warnings. +# +# reflection.h casts a pointer to a member function to an another pointer to a +# member function to store it in a structure, but cast it back before a call. +# It is legal and does not lead to an undefined behaviour. +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-cast-function-type") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-cast-function-type") + include_directories(${LIBEV_INCLUDE_DIR}) include_directories(${LIBEIO_INCLUDE_DIR}) include_directories(${LIBCORO_INCLUDE_DIR}) diff --git a/src/http_parser.c b/src/http_parser.c index 94d7bc04f..d485f5b44 100644 --- a/src/http_parser.c +++ b/src/http_parser.c @@ -292,6 +292,7 @@ http_parse_header_line(struct http_parser *prsr, char **bufp, default: return HTTP_PARSE_INVALID; } + break; /* http_header name */ case sw_name: c = lowcase[ch]; diff --git a/src/reflection.h b/src/reflection.h index 40818c13f..45921c4ea 100644 --- a/src/reflection.h +++ b/src/reflection.h @@ -106,10 +106,10 @@ struct method_info { }; }; -#define type_foreach_method(m, method) \ +#define type_foreach_method(m, method) \ for(const struct type_info *_m = (m); _m != NULL; _m = _m->parent) \ - for (const struct method_info *(method) = _m->methods; \ - (method)->name != NULL; (method)++) + for (const struct method_info *method = _m->methods; \ + method->name != NULL; method++) inline const struct method_info * type_method_by_name(const struct type_info *type, const char *name) diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index 943788b94..b6ffe1cfa 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -5,6 +5,14 @@ endif() file(GLOB all_sources *.c *.cc) set_source_files_compile_flags(${all_sources}) +# Suppress noise GCC 8 warnings. +# +# reflection.h casts a pointer to a member function to an another pointer to a +# member function to store it in a structure, but cast it back before a call. +# It is legal and does not lead to an undefined behaviour. +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-cast-function-type") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-cast-function-type") + include_directories(${PROJECT_SOURCE_DIR}/src) include_directories(${PROJECT_BINARY_DIR}/src) include_directories(${PROJECT_SOURCE_DIR}/src/box) -- 2.19.0