cpp-best-practices / cpp-best-practices/cmake_template

Put back `-Wsign-conversion` for gcc in CompilerWarnings.cmake

Open Beginner friendly
#162 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
CMake
Stars
1.8k
Forks
204
PR merge metrics
No merged PRs in 30d

Description

Issue #76 / PR #149 removed the `-Wsign-conversion` flag in *CompilerWarnings.cmake*. This may be OK for Clang and gcc using C, but it is not OK for gcc using C++.

The [gcc documentation](https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wsign-conversion) says:

> In **C**, this option is enabled also by -Wconversion.

So NOT for C++.

See this demo for an example: https://godbolt.org/z/8YMbWr3Wx

Using gcc 15.2, compiling the code with `-O3 -std=c++23 -Werror -Wconversion` will work, but using `-O3 -std=c++23 -Werror -Wconversion -Wsign-conversion` will not.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in CompilerWarnings.cmake and inspect how warning flags are selected for gcc and C++. Reproduce the provided C++23 example with gcc using -Wconversion and -Wsign-conversion. Done means gcc C++ builds again with -Wsign-conversion enabled while preserving the stated C and Clang behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp
Domain
build-system
Issue type
Bug
Difficulty
2/5
Estimated time
Under an hour
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
85/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.