From ffdaf0fb211d3a2920e480c7a8315cff98fe1b19 Mon Sep 17 00:00:00 2001 From: menete Date: Fri, 8 Jun 2018 20:41:06 +0200 Subject: [PATCH] fix gcc build (gcc 7) (#690) simple solution, disable the specific warning --- .travis.yml | 19 +++++++++---------- include/gsl/multi_span | 14 ++++++++++++++ include/gsl/span | 14 ++++++++++++++ 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index d2e4d9d..c373da2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -160,17 +160,16 @@ matrix: - env: COMPILER=g++-6 BUILD_TYPE=Release addons: *gcc6 - # Currently fails due to #525 - ## GCC 7 - #- env: COMPILER=g++-7 BUILD_TYPE=Debug - # addons: &gcc7 - # apt: - # packages: g++-7 - # sources: - # - ubuntu-toolchain-r-test + # GCC 7 + - env: COMPILER=g++-7 BUILD_TYPE=Debug + addons: &gcc7 + apt: + packages: g++-7 + sources: + - ubuntu-toolchain-r-test - #- env: COMPILER=g++-7 BUILD_TYPE=Release - # addons: *gcc7 + - env: COMPILER=g++-7 BUILD_TYPE=Release + addons: *gcc7 install: diff --git a/include/gsl/multi_span b/include/gsl/multi_span index 65e65a1..f697093 100644 --- a/include/gsl/multi_span +++ b/include/gsl/multi_span @@ -51,6 +51,16 @@ #endif // _MSC_VER < 1910 #endif // _MSC_VER +// GCC 7 does not like the signed unsigned missmatch (size_t ptrdiff_t) +// While there is a conversion from signed to unsigned, it happens at +// compiletime, so the compiler wouldn't have to warn indiscriminently, but +// could check if the source value actually doesn't fit into the target type +// and only warn in those cases. +#if __GNUC__ > 6 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif + #ifdef GSL_THROW_ON_CONTRACT_VIOLATION #define GSL_NOEXCEPT /*noexcept*/ #else @@ -2225,4 +2235,8 @@ general_span_iterator operator+(typename general_span_iterator::diff #endif // _MSC_VER +#if __GNUC__ > 6 +#pragma GCC diagnostic pop +#endif // __GNUC__ > 6 + #endif // GSL_MULTI_SPAN_H diff --git a/include/gsl/span b/include/gsl/span index dd2d053..2fa9cc5 100644 --- a/include/gsl/span +++ b/include/gsl/span @@ -58,6 +58,16 @@ #endif // _MSC_VER +// GCC 7 does not like the signed unsigned missmatch (size_t ptrdiff_t) +// While there is a conversion from signed to unsigned, it happens at +// compiletime, so the compiler wouldn't have to warn indiscriminently, but +// could check if the source value actually doesn't fit into the target type +// and only warn in those cases. +#if __GNUC__ > 6 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif + namespace gsl { @@ -749,4 +759,8 @@ constexpr ElementType& at(span s, index i) #pragma warning(pop) #endif // _MSC_VER +#if __GNUC__ > 6 +#pragma GCC diagnostic pop +#endif // __GNUC__ > 6 + #endif // GSL_SPAN_H