Attempting to build cawlign fails on modern compilers (e.g. Clang 20) with a narrowing conversion error:
/home/sweaver/cawlign/src/scoring.cpp:154:28: error: constant expression evaluates to -1 which cannot be narrowed to type 'char' [-Wc++11-narrowing]
154 | char allowed_aa [255] {-1};
| ^~
| static_cast( )
This is caused by initializing a char array with -1, which is not portable and disallowed in C++11 and later when char is unsigned.
Steps to Reproduce:
git clone https://github.com/your-org/cawlign.git
cd cawlign
cmake .
make
Environment:
• Clang 20
• C++11 or higher
Suggested Fix:
Replace the declaration:
char allowed_aa[255] {-1};
with:
signed char allowed_aa[255];
std::fill_n(allowed_aa, 255, -1);
Or, cast explicitly (not portable if char is unsigned):
char allowed_aa[255] = { static_cast(-1) };
Workaround:
Build with -Wno-c++11-narrowing:
cmake -DCMAKE_CXX_FLAGS="-Wno-c++11-narrowing" .
But a code fix is preferable for portability.