From 5e8d03e90dc66e5ecc4ea9240b82c32eea64ee42 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Sat, 9 Feb 2019 10:30:07 -0500 Subject: [PATCH 1/3] Add GCC 4.6 to the TravisCI build. With `-march=native`, we see assembler error messages like those described in https://github.com/uzh-rpg/rpg_svo/issues/7 . --- .travis.yml | 16 +++++++++++++++- Makefile.simple | 13 ++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c3159872..d0d44a57 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,20 @@ services: - docker matrix: include: + - os: linux + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - gcc-4.6 + - g++-4.6 + env: >- + TRAVIS_OS_NAME=linux + TRAVIS_BUILD_SYSTEM=Makefile + HYPERROGUE_CXX=g++-4.6 + HYPERROGUE_USE_GLEW=1 + HYPERROGUE_USE_PNG=1 - os: linux compiler: gcc env: >- @@ -126,7 +140,7 @@ script: ./configure CXXFLAGS="-Wall -Werror" make elif [[ "$TRAVIS_BUILD_SYSTEM" == "Makefile" ]]; then - make -f Makefile.simple + make -f Makefile.simple CXX="${HYPERROGUE_CXX-g++}" elif [[ "$TRAVIS_BUILD_SYSTEM" == "emscripten" ]]; then docker run --rm -v $(pwd):/src trzeci/emscripten make -f Makefile.simple emscripten else diff --git a/Makefile.simple b/Makefile.simple index 64627d6d..8a78314a 100644 --- a/Makefile.simple +++ b/Makefile.simple @@ -33,7 +33,11 @@ else ifneq (,$(findstring clang,$(TOOLCHAIN_VERSION_S))) TOOLCHAIN := clang else - TOOLCHAIN := gcc + ifneq (,$(findstring 4.6.,$(TOOLCHAIN_VERSION_S))) + TOOLCHAIN := gcc46 + else + TOOLCHAIN := gcc + endif endif endif @@ -91,6 +95,13 @@ ifeq (${TOOLCHAIN},gcc) CXXFLAGS_EARLY += -Wno-maybe-uninitialized -Wno-missing-field-initializers -Wno-unused-parameter endif +ifeq (${TOOLCHAIN},gcc46) + CXXFLAGS_EARLY += -std=c++0x + CXXFLAGS_EARLY += -W -Wall -Wextra -Werror + CXXFLAGS_EARLY += -Wno-missing-field-initializers -Wno-unused-parameter + CXXFLAGS_EARLY += -DUSE_STDFUNCTION=1 +endif + ifeq (${TOOLCHAIN},mingw) CXXFLAGS_EARLY += -std=c++11 -march=native CXXFLAGS_EARLY += -W -Wall -Wextra -Werror From 5efd1f56624920f462149bf10f584a0299a634f5 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Sun, 10 Feb 2019 14:36:09 -0500 Subject: [PATCH 2/3] Fix a compiler warning from GCC 4.6.4. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The variable name in this warning is "pre-phi-tmp", as in, some compiler internals spilling into userspace. But I think it's probably referring to `bestV`, and indeed, this initialization silences the warning. geometry2.cpp: In function ‘void hr::virtualRebaseSimple(hr::heptagon*&, hr::transmatrix&)’: geometry2.cpp:366:7: error: ‘prephitmp.91209’ may be used uninitialized in this function [-Werror=uninitialized] --- geometry2.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/geometry2.cpp b/geometry2.cpp index 46b9ff79..f49f9d60 100644 --- a/geometry2.cpp +++ b/geometry2.cpp @@ -356,7 +356,7 @@ void virtualRebaseSimple(heptagon*& base, transmatrix& at) { heptagon *newbase = NULL; - transmatrix bestV; + transmatrix bestV {}; for(int d=0; d Date: Sun, 10 Feb 2019 11:49:55 -0500 Subject: [PATCH 3/3] Get hyper_function.h compiling on GCC 4.6. We must avoid the following features: - the `using` syntax for typedefs - alias templates (so, rename `hyper_function` to `function`) - the `override` keyword - defaulted virtual destructors --- Makefile.simple | 1 - hyper_function.h | 55 ++++++++++++++++++------------------------------ sysconfig.h | 4 ---- 3 files changed, 20 insertions(+), 40 deletions(-) diff --git a/Makefile.simple b/Makefile.simple index 8a78314a..491c766d 100644 --- a/Makefile.simple +++ b/Makefile.simple @@ -99,7 +99,6 @@ ifeq (${TOOLCHAIN},gcc46) CXXFLAGS_EARLY += -std=c++0x CXXFLAGS_EARLY += -W -Wall -Wextra -Werror CXXFLAGS_EARLY += -Wno-missing-field-initializers -Wno-unused-parameter - CXXFLAGS_EARLY += -DUSE_STDFUNCTION=1 endif ifeq (${TOOLCHAIN},mingw) diff --git a/hyper_function.h b/hyper_function.h index 97a71d18..3e4c5ddd 100644 --- a/hyper_function.h +++ b/hyper_function.h @@ -1,67 +1,54 @@ #pragma once -#if USE_STDFUNCTION - -#include -namespace hr { - using std::function; -} // namespace hr - -#else - #include #include namespace hr { template -class hyper_function; - -template -using function = hyper_function; +class function; template -struct hyper_function_state_base { +struct function_state_base { virtual R call(Args...) const = 0; - virtual hyper_function_state_base *clone() const = 0; - virtual ~hyper_function_state_base() = default; + virtual function_state_base *clone() const = 0; + virtual ~function_state_base() {} }; template -struct hyper_function_state : hyper_function_state_base { - using Self = hyper_function_state; +struct function_state : function_state_base { T t_; - explicit hyper_function_state(T t) : t_(std::move(t)) {} - R call(Args... args) const override { + explicit function_state(T t) : t_(std::move(t)) {} + R call(Args... args) const /*override*/ { return const_cast(t_)(static_cast(args)...); } - hyper_function_state_base *clone() const override { - return new Self(*this); + function_state_base *clone() const /*override*/ { + return new function_state(*this); } }; template -class hyper_function +class function { - hyper_function_state_base *ptr_ = nullptr; + function_state_base *ptr_; public: - hyper_function() = default; + function() : ptr_(nullptr) {} template::type>()(std::declval()...)))> - hyper_function(Callable&& t) : - ptr_(new hyper_function_state::type, R, Args...>(static_cast(t))) + function(Callable&& t) : + ptr_(new function_state::type, R, Args...>(static_cast(t))) {} - ~hyper_function() { + ~function() { delete ptr_; } - hyper_function(hyper_function& rhs) : ptr_(rhs.ptr_ ? rhs.ptr_->clone() : nullptr) {} - hyper_function(const hyper_function& rhs) : ptr_(rhs.ptr_ ? rhs.ptr_->clone() : nullptr) {} - hyper_function(hyper_function&& rhs) noexcept : ptr_(rhs.ptr_) { rhs.ptr_ = nullptr; } - hyper_function(const hyper_function&& rhs) = delete; + function(function& rhs) : ptr_(rhs.ptr_ ? rhs.ptr_->clone() : nullptr) {} + function(const function& rhs) : ptr_(rhs.ptr_ ? rhs.ptr_->clone() : nullptr) {} + function(function&& rhs) noexcept : ptr_(rhs.ptr_) { rhs.ptr_ = nullptr; } + function(const function&& rhs) = delete; - void operator=(hyper_function rhs) noexcept { + void operator=(function rhs) noexcept { std::swap(ptr_, rhs.ptr_); } @@ -75,5 +62,3 @@ public: }; } // namespace hr - -#endif diff --git a/sysconfig.h b/sysconfig.h index 67c630c9..e8bd2eef 100644 --- a/sysconfig.h +++ b/sysconfig.h @@ -72,10 +72,6 @@ #define NOLICENSE ISSTEAM #endif -#ifndef USE_STDFUNCTION -#define USE_STDFUNCTION ISSTEAM -#endif - #ifndef CAP_SHADER #define CAP_SHADER CAP_GL #endif