Uh oh!
There was an error while loading. Please reload this page.
Document the size of bool - #46156
Conversation
SimonSapin
commented
Nov 21, 2017
It is always 1, right? |
rust-highfive
commented
Nov 21, 2017
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. |
This is historically not guaranteed on purpose rust-lang/rfcs#954
/cc @rust-lang/lang See also rust-lang/rfcs#992 |
Worth noting that rust-lang/rfcs#954 proposed far more than documenting the size, it proposed guaranteeing a encoding of In contrast, guaranteeing a |
durka
commented
Nov 21, 2017
The values true=1, false=0 are documented: https://doc.rust-lang.org/reference/behavior-considered-undefined.html |
bluss
commented
Nov 21, 2017
The reference is not official rust docs and it is not a real reference yet, unfortunately. |
est31
commented
Nov 21, 2017
@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? |
bluss
commented
Nov 21, 2017
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 |
durka
commented
Nov 21, 2017
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"? |
cramertj
commented
Nov 21, 2017
@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. |
scottmcm
commented
Nov 21, 2017
Hmm, so the impact of this change would be to put the compile-time-validity of |
est31
commented
Nov 21, 2017
So as the ABI of bool seems to be not specified, please see my PR #46176 to lint about bool in FFI usage. |
egilburg
commented
Nov 21, 2017
Perhaps document |
hanna-kruppe
commented
Nov 22, 2017
It appears that C doesn't specify the size of |
The ABI of bool is reserved, see these links: * rust-lang/rfcs#954 (comment) * rust-lang#46156 (comment) * rust-lang/rfcs#992 Currently the improper_ctypes lint is inconsistent with that position by treating bools as if they had a specified ABI. To fix this inconsistency, this changes treatment of bools by the lint. This might break some code, so possibly it has to be phased in slowly...
withoutboats
commented
Nov 22, 2017
IMO the size of bool should be defined as the same as the size of |
withoutboats
commented
Nov 22, 2017
Basically I think we should just accept RFC 954 at this point. |
Havvy
commented
Nov 22, 2017
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 |
I wonder why should |
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. |
SimonSapin
commented
Nov 24, 2017
hsivonen wrote in a thread that mentioned this PR:
I think that’s a good point, and we should decide that Rust’s |
aturon
commented
Nov 28, 2017
Nominated for lang team discussion. |
SimonSapin
commented
Dec 17, 2017
You’re looking for https://crates.io/crates/bit-vec. This is not possible with |
scottmcm
commented
Dec 17, 2017
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 |
kennytm
commented
Jan 10, 2018
Triage ping @rust-lang/lang! It seems we still haven't got a clear decision... |
nikomatsakis
commented
Jan 18, 2018
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 |
petrochenkov
commented
Jan 18, 2018
Additional question for the list:
C |
vojtechkral
commented
Jan 19, 2018
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:
|
SimonSapin
commented
Jan 19, 2018
(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.) |
est31
commented
Feb 2, 2018
The FCP has been resolved: #46176 (comment) Please merge this now! |
withoutboats
commented
Feb 2, 2018
@bors r+ |
bors
commented
Feb 2, 2018
📌 Commit 219ba51 has been approved by |
kennytm
commented
Feb 2, 2018
@bors rollup |
Document the size of bool
No description provided.