Skip to content

Fix type_traits_test on platforms where char is unsigned#192

Open
singhc7 wants to merge 1 commit into
atcoder:masterfrom
singhc7:fix-char-signedness-test
Open

Fix type_traits_test on platforms where char is unsigned#192
singhc7 wants to merge 1 commit into
atcoder:masterfrom
singhc7:fix-char-signedness-test

Conversation

@singhc7
Copy link
Copy Markdown

@singhc7 singhc7 commented May 8, 2026

Summary

Fixes the static_assert in test/unittest/type_traits_test.cpp that assumes char is signed. On platforms where char is unsigned by default (e.g. aarch64-linux, ppc64), to_unsigned_t<char> resolves to char rather than unsigned char, and the original assertion fails to compile.

Guards the assertion with CHAR_MIN < 0 so the correct relationship is checked on each platform, and adds #include <climits> for the macro.

The library itself is correct on these platforms — only this test assertion was platform-unsafe.

Changes

  • test/unittest/type_traits_test.cpp: add #include <climits>, guard the to_unsigned_t<char> assertion with CHAR_MIN < 0.

Verification

Built and ran the full test suite on aarch64-linux (where the failure originally manifested):

100% tests passed, 0 tests failed out of 126

The signed-char branch is the original upstream assertion, unchanged in behavior on platforms where char is signed.

Related

Closes #191

@singhc7
Copy link
Copy Markdown
Author

singhc7 commented May 9, 2026

Hi @yosupo06!

Sorry to ping directly — I opened a small PR (#192) that fixes type_traits_test.cpp on platforms where char is unsigned by default (aarch64-linux, ppc64, etc.). The library itself works fine on these platforms; only one static_assert was making a signedness assumption.

Whenever you have a moment, would appreciate a look. Happy to make any changes if you'd prefer a different approach. Thanks for maintaining ac-library!

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

Successfully merging this pull request may close these issues.

type_traits_test fails to compile on platforms where char is unsigned

1 participant