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

[bit.cast] simplify "unsigned ordinary character type" to unsigned char #6463

Closed
wants to merge 1 commit into from

Conversation

Eisenwave
Copy link
Contributor

Ordinary character types include char, signed char, and unsigned char.

Saying unsigned ordinary character type is just an obscure way of saying unsigned char, and should be simplified.

@jwakely
Copy link
Member

jwakely commented Aug 19, 2023

char can be unsigned.

@Eisenwave
Copy link
Contributor Author

Eisenwave commented Aug 19, 2023

char can be unsigned.

So if char happens to have unsigned char as its underlying type because of an implementation-defined choice, then std::bit_cast is allowed to produce an indeterminate value?

If this is really the intended behavior, then I think this deserves a note at least, because it is really obscure.

The way that [basic.fundamental] p7 is phrased, char cannot be unsigned char, but it can have an unsigned underlying type. This puts into question whether char ever is unsigned.

Furthermore (and this is leaving the realm of editorial issues), in all other circumstances known to me, "unsigned" char does not behave specially, only unsigned char does. See [intro.object] p13 for instance. This behavior of "unsigned" char being special breaks the norm, and is very surprising.

@Eisenwave
Copy link
Contributor Author

I've looked into it, and the issue which introduced the wording is https://cplusplus.github.io/CWG/issues/2482.html.

This issue uses the term byte-like type, which normally refers to unsigned char and std::byte, but [basic.indet] also uses unsigned ordinary character type. If there is any issue, and there probably isn't, then it starts with [basic.indet].

@Eisenwave
Copy link
Contributor Author

Related #5070

@frederick-vs-ja
Copy link
Contributor

Ideally, [basic.indet] should be simultaneously changed, which fixes #5070. However, a CWG issue seems needed for this.

@Eisenwave
Copy link
Contributor Author

Ideally, [basic.indet] should be simultaneously changed, which fixes #5070. However, a CWG issue seems needed for this.

You're right, and after looking further into it, I've opened cplusplus/CWG#403

@tkoeppe
Copy link
Contributor

tkoeppe commented Nov 10, 2023

I don't think there's anything for us to do here editorially.

@tkoeppe tkoeppe closed this Nov 10, 2023
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.

None yet

4 participants