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

Specify signed char #1940

Closed
wants to merge 1 commit into from
Closed

Specify signed char #1940

wants to merge 1 commit into from

Conversation

tasleson
Copy link

Addresses #1939

x86 architecture default to signed characters. Other architectures
default to unsigned characters. When building on non-x86 arch we
get the following error

./json.hpp:22700:42:   required from here
./json.hpp:8494:24: error: comparison is always true due to limited
                           range of data type [-Werror=type-limits]
 8494 |             if ('\x00' <= c and c <= '\x1F')
      |                 ~~~~~~~^~~~

Signed-off-by: Tony Asleson [email protected]

x86 architecture default to signed characters.  Other architectures
default to unsigned characters.  When building on non-x86 arch we
get the following error

./json.hpp:22700:42:   required from here
./json.hpp:8494:24: error: comparison is always true due to limited
                           range of data type [-Werror=type-limits]
 8494 |             if ('\x00' <= c and c <= '\x1F')
      |                 ~~~~~~~^~~~

Signed-off-by: Tony Asleson <[email protected]>
@tasleson tasleson requested a review from nlohmann as a code owner February 12, 2020 19:45
@jaredgrubb
Copy link
Contributor

Hmm, not sure if that's the best fix. Maybe change the condition to if (static_cast<unsigned char>(c) <= '\x1F')?

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 3c3c11a on tasleson:specify_sign into 973c52d on nlohmann:develop.

@nlohmann
Copy link
Owner

We may use SFINAE to decide between a signed char and an unsigned char version. Changing everything internally to signed char seems odd.

@stale
Copy link

stale bot commented Mar 17, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated label Mar 17, 2020
Copy link
Owner

@nlohmann nlohmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not like this change just to fix a type-limits warning. The must be a better way.

@stale stale bot removed the state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated label Mar 20, 2020
@tasleson tasleson closed this Mar 31, 2020
@tasleson tasleson deleted the specify_sign branch March 31, 2020 18:14
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.

4 participants