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

Make enums derived from uint16_t at least or migrate to libfmt, to avoid garbled log in OPENRAVE_ASSERT_OP #1365

Open
cielavenir opened this issue Mar 16, 2024 · 4 comments
Assignees

Comments

@cielavenir
Copy link
Collaborator

Today I read boost::format source code and it turned out that it was just a frontend of stringstream (eg boost::str(boost::format("%x") % "xyz") is the same as std::cout << std::setbase(16) << "xyz" << std::endl;).

ostream, including stringstream, handles uint8_t in the same way as char ( cf https://cplusplus.com/reference/ostream/basic_ostream/operator-free/ ).

Recently openrave changed some enums derived from uint8_t ( d841c76 ). It is problematic when the values are directly passed to OPENRAVE_ASSERT_OP because if the assertion fails, boost::format is called, and the value are printed as char, which is unexpected and garbled.
We paid some attention to pass the value with casting to int, but it is forgettable ( eg planningcommon https://tiny.mujin.co.jp/mcyzo ).
To avoid further confusion, enums should be derived from uint16_t at least.
Alternatively I suggest to migrate to libfmt ( we discussed this years ago https://tiny.mujin.co.jp/czkx4 ), which does not have this uint8_t output issue.

/cc @ntohge

@cielavenir cielavenir changed the title Make enums derived from uint16_t at least or migrate to libfmt Make enums derived from uint16_t at least or migrate to libfmt, to avoid garbled log in OPENRAVE_ASSERT_OP Mar 17, 2024
@cielavenir
Copy link
Collaborator Author

cc @yoshikikanemoto (he got an issue related to this, where pybind11 exception message is not garbled but nothing is shown)

@cielavenir
Copy link
Collaborator Author

maybe product team want to take a look @felixvd @hemangandhi

@hemangandhi
Copy link
Collaborator

+1 on migrating to fmt -- I think that's a good future direction.

That said, we might want to start with moving to uint16_t so that {fmt} doesn't block pybind-related work.

@rdiankov
Copy link
Owner

rdiankov commented Aug 19, 2024

Doesn't sound like a blocking or important issue at the moment....

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

3 participants