anura-engine / anura

Anura Engine
Other
384 stars 78 forks source link

-Wno-sign-compare not set when CXX is default #293

Open spixi opened 4 years ago

spixi commented 4 years ago

Because of the heavy uses of

    for(int n = 0; n !=v.size(); ++n)

instead of

    for(auto it = v.begin(); it!=v.end() ++it)

there are many warnings on systems, which have typeid(std::vector<T>::size_type) == typeid(long unsigned).

I am currently running GCC 9.1.0 and don’t have the environment variable CXX set, so it defaults to c++.

user@machine /mnt/hdd/home/mari/anura $ which c++ /usr/x86_64-pc-linux-gnu/gcc-bin/9.1.0/c++ user@machine /mnt/hdd/home/mari/anura $ readlink /usr/x86_64-pc-linux-gnu/gcc-bin/9.1.0/c++ x86_64-pc-linux-gnu-c++

I guess, the following coding is wrong:

ifneq (,$(findstring clang, `$(CXX)`))
SANITIZE_UNDEFINED=
BASE_CXXFLAGS += -Qunused-arguments -Wno-unknown-warning-option -Wno-deprecated-register
ifeq ($(USE_LUA), yes)
BASE_CXXFLAGS += -Wno-pointer-bool-conversion -Wno-parentheses-equality
endif
else ifneq (, $(findstring g++, `$(CXX)`))
GCC_GTEQ_490 := $(shell expr `$(CXX) -dumpversion | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$$/&00/'` \>= 40900)
GCC_GTEQ_510 := $(shell expr `$(CXX) -dumpversion | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$$/&00/'` \>= 50100)
BASE_CXXFLAGS += -Wno-literal-suffix -Wno-sign-compare

ifeq "$(GCC_GTEQ_510)" "1"
BASE_CXXFLAGS += -Wsuggest-override
endif

ifeq "$(GCC_GTEQ_490)" "1"
BASE_CXXFLAGS += -fdiagnostics-color=auto
else
SANITIZE_UNDEFINED=
endif
endif

The problem is, that it only checks for g++ and not for c++, so it never adds the -Wno-sign-compare flag, when it should

galegosimpatico commented 4 years ago

I agree sanitization triggered by a g++ in CXX should be triggered by a c++ in CXX. If that c++ is pointing to a g++ actually.