Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upDocument the size of bool #46156
Conversation
rust-highfive
assigned
BurntSushi
Nov 21, 2017
This comment has been minimized.
This comment has been minimized.
|
It is always 1, right? |
This comment has been minimized.
This comment has been minimized.
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @BurntSushi (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
kennytm
added
the
S-waiting-on-review
label
Nov 21, 2017
This comment has been minimized.
This comment has been minimized.
|
This is historically not guaranteed on purpose rust-lang/rfcs#954
/cc @rust-lang/lang See also rust-lang/rfcs#992 |
This comment has been minimized.
This comment has been minimized.
|
Worth noting that rust-lang/rfcs#954 proposed far more than documenting the size, it proposed guaranteeing a encoding of In contrast, guaranteeing a |
This comment has been minimized.
This comment has been minimized.
|
The values true=1, false=0 are documented: https://doc.rust-lang.org/reference/behavior-considered-undefined.html |
This comment has been minimized.
This comment has been minimized.
|
The reference is not official rust docs and it is not a real reference yet, unfortunately. |
This comment has been minimized.
This comment has been minimized.
|
@bluss then remove that statement from the reference. And no it is official documentation. Otherwise why is it on the doc.rust-lang.org domain? |
This comment has been minimized.
This comment has been minimized.
|
Nightly version has a better banner and a link to the nursery repo where it's developed: https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html |
This comment has been minimized.
This comment has been minimized.
|
Then we should close this PR as writing down the size of bool won't have any weight... is there a list of "decisions that have actually been made and can be trusted"? |
This comment has been minimized.
This comment has been minimized.
|
@durka IMO the authoritative Rust documentation is the standard library's documentation, as the guarantees it specifies are part of the library, and therefore part of Rust's stability guarantees. |
This comment has been minimized.
This comment has been minimized.
|
Hmm, so the impact of this change would be to put the compile-time-validity of |
est31
added a commit
to est31/rust
that referenced
this pull request
Nov 21, 2017
This comment has been minimized.
This comment has been minimized.
|
So as the ABI of bool seems to be not specified, please see my PR #46176 to lint about bool in FFI usage. |
This comment has been minimized.
This comment has been minimized.
egilburg
commented
Nov 21, 2017
|
Perhaps document |
This comment has been minimized.
This comment has been minimized.
|
It appears that C doesn't specify the size of |
est31
added a commit
to est31/rust
that referenced
this pull request
Nov 22, 2017
This comment has been minimized.
This comment has been minimized.
|
IMO the size of bool should be defined as the same as the size of |
This comment has been minimized.
This comment has been minimized.
|
Basically I think we should just accept RFC 954 at this point. |
This comment has been minimized.
This comment has been minimized.
|
I added the table in #44648 and checked what people said on IRC around the time. I'm not seeing any reference to I do have a reference PR where I added it though, but it looks like I'll have to remove that line. About the UB section of the reference — it's immaterial to this discussion. It's stating that the valid values of |
This comment has been minimized.
This comment has been minimized.
I wonder why should |
This comment has been minimized.
This comment has been minimized.
|
That also seems fine. I think the larger thrust of my objective is that we should stop delaying action based on theoretical concerns. There are neither viable optimizations nor major platforms which conflict with specifying the obvious representation of bool. Any solution in which we specify the repr of boolean as what it has been and will always be on major platforms is good. |
This comment has been minimized.
This comment has been minimized.
|
hsivonen wrote in a thread that mentioned this PR:
I think that’s a good point, and we should decide that Rust’s |
kennytm
added
the
T-lang
label
Nov 24, 2017
aturon
added
the
I-nominated
label
Nov 28, 2017
This comment has been minimized.
This comment has been minimized.
|
Nominated for lang team discussion. |
kennytm
added
S-waiting-on-team
and removed
S-waiting-on-review
labels
Dec 4, 2017
This comment has been minimized.
This comment has been minimized.
|
Hi @rust-lang/lang, triage ping. Is there any update on this? Should this PR (and also #46176) be kept open until a decision is reached? |
This comment has been minimized.
This comment has been minimized.
nicodemus26
commented
Dec 17, 2017
|
@vojtechkral It would seem that
As an aside, it would be pretty nice to have |
This comment has been minimized.
This comment has been minimized.
You’re looking for https://crates.io/crates/bit-vec. This is not possible with |
This comment has been minimized.
This comment has been minimized.
C++ has experience with that, and it turned out to be better as opt-in instead of magic: https://isocpp.org/blog/2012/11/on-vectorbool |
This comment has been minimized.
This comment has been minimized.
|
Triage ping @rust-lang/lang! It seems we still haven't got a clear decision... |
This comment has been minimized.
This comment has been minimized.
|
Cross-posting from the internals thread: We finally got around to discussing this in the @rust-lang/lang meeting. We had the following questions, perhaps someone may be in a position to answer authoritatively:
Our preference is to define Relevant to this RFC, @SimonSapin or others, do you think that defining |
nikomatsakis
removed
the
I-nominated
label
Jan 18, 2018
This comment has been minimized.
This comment has been minimized.
|
Additional question for the list:
C |
This comment has been minimized.
This comment has been minimized.
From N1570, §6.2.5:
§6.3.1.2:
Ie. I believe from the standard's point of view cppreference.com also notes a consequence:
|
This comment has been minimized.
This comment has been minimized.
(Replying since I’m mentioned by name. “Better” is a big word. I have no idea. I submitted this PR because it had not occurred to be that this could be otherwise.) |
This comment has been minimized.
This comment has been minimized.
|
The FCP has been resolved: #46176 (comment) Please merge this now! |
This comment has been minimized.
This comment has been minimized.
|
@bors r+ |
This comment has been minimized.
This comment has been minimized.
|
|
kennytm
added
S-waiting-on-bors
and removed
S-waiting-on-team
labels
Feb 2, 2018
This comment has been minimized.
This comment has been minimized.
|
@bors rollup |
SimonSapin commentedNov 21, 2017
No description provided.