Skip to content

Cast the constant to the right type - FIX #2156 #2171

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

Closed
wants to merge 1 commit into from

Conversation

airween
Copy link
Member

@airween airween commented Sep 26, 2019

A possible solution for #2156.

@zimmerle
Copy link
Contributor

Hi @airween, hide the warning is definitely not the solution for the problem.

@zimmerle zimmerle closed this Sep 30, 2019
@airween
Copy link
Member Author

airween commented Sep 30, 2019

Hi @zimmerle,

could you explain why is this just hiding of warning?

I made a small test file to demonstrate my idea:
https://gist.github.com/airween/c2f3ff400e4c4a94dcbed9aec6eca48a

Here is my opinion:

  • the std::string is a sequence with element type char, therefore each item value could be between -127 and 128
  • consider somehow there is an item with value 160 - see the example line 25.
  • when the casting comes (line 26-27), then the values converted from unsigned char to signed char, so the 160 will -96
  • it's same what the static_cast<> does

In the example you can see that's not just the warning hide, it really removes the NBSP from sequence.

May be I'm wrong, but I'm very curious your opinion.

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.

2 participants