Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
spixi opened this issue Nov 18, 2019 · 1 comment
Open

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

spixi opened this issue Nov 18, 2019 · 1 comment

Comments

@spixi
Copy link

spixi commented Nov 18, 2019

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
Copy link
Contributor

galegosimpatico commented Jul 23, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants