[BUG]: error: static assertion failed: char should be cast to either signed char or unsigned char
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 18k
- Forks
- 2.3k
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 10
Description
Required prerequisites
- Make sure you've read the documentation. Your issue may be addressed there.
- Search the issue tracker and Discussions to verify that this hasn't already been reported. +1 or comment there if it has.
- Consider asking first in the Gitter chat room or in a Discussion.
What version (or hash if on master) of pybind11 are you using?
2.11.1
Problem description
I'm trying to compile pybind11 tests and compilatoin fails here:
pybind11-2.11.1/tests/test_enum.cpp:95:16: error: static assertion failed: char should be cast to either signed char or unsigned char
92 | py::detail::any_of<
| ~~~~~~~~~~~~~~~~~~~
93 | std::is_same<py::enum_<ScopedCharEnum>::Scalar, signed char>, // e.g. gcc on x86
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
94 | std::is_same<py::enum_<ScopedCharEnum>::Scalar, unsigned char> // e.g. arm linux
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
95 | >::value,
| ~~~^~~~~
I think the assertion is wrong since char, unsigned char and signed char are three distinct types.
Reference:
https://en.cppreference.com/w/cpp/language/types
https://stackoverflow.com/questions/2054939/is-char-signed-or-unsigned-by-default
Reproducible example code
No response
Is this a regression? Put the last known working version here if it is.
Not a regression
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in tests/test_enum.cpp around line 95 and inspect the static assertion for py::enum_::Scalar. Reproduce the test compilation failure, then verify the assertion against the distinct char types described in the issue; done means the tests compile without that failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100