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 upLint for the reserved ABI of bool #46176
Conversation
rust-highfive
assigned
michaelwoerister
Nov 21, 2017
This comment has been minimized.
This comment has been minimized.
|
(rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
|
I don't neccessarily endorse this PR myself. If the apparent inconsistency gets fixed by having |
est31
force-pushed the
est31:bool_lint
branch
from
c0f63c9
to
f3321b1
Nov 22, 2017
This comment has been minimized.
This comment has been minimized.
|
As someone who has (successfully, AFAICT, on multiple platforms—the ones Firefox 56+ runs on) used |
This comment has been minimized.
This comment has been minimized.
|
Nominating for discussion in the @rust-lang/compiler team meeting. |
michaelwoerister
added
T-compiler
I-nominated
labels
Nov 22, 2017
This comment has been minimized.
This comment has been minimized.
|
To elaborate: Not having a type that is equivalent to As for Rust As for weird embedded C compilers having weird |
kennytm
added
the
S-waiting-on-team
label
Nov 22, 2017
This comment has been minimized.
This comment has been minimized.
|
New lints require an RFC. This kind of blurs the line. |
This comment has been minimized.
This comment has been minimized.
|
This is more a bugfix than a new lint addition or something like that ("feature change" etc). Unless I understood it wrongly, the purpose of the |
nagisa
added
the
T-lang
label
Nov 23, 2017
This comment has been minimized.
This comment has been minimized.
|
When |
This comment has been minimized.
This comment has been minimized.
It is established practice that something can be broken if it only works due to a bug. See this search. And the current behaviour is clearly a bug: the ABI of bool is not specified yet, even though the lint assumes that it is specified. Probably this change has to be phased in slowly, as the other breaking changes, I'll change my PR if the compiler team has deemed that they want to do the change. |
This comment has been minimized.
This comment has been minimized.
|
What you are saying is that this is not credible as a soundness bug fix, even of a lint. I understand the not credible part. On the other hand, ffi is unsafe code zone and there are many details the compiler can not check for you there. It should only be good if we get better at this approximate and pragmatic safety work of warning about portability and safety issues in code outside of safe rust. |
This comment has been minimized.
This comment has been minimized.
|
There's a big difference between a theoretical break to fix a soundness bug and withdrawing a practically working behavior that's in use in deployed code over a theoretical concern. As for FFI being unsafe, the use of a particular type in a signature is not the kind of unsafe that the compiler couldn't have checked, so I don't think FFI being unsafe makes it OK to make a breaking change. Withdrawing a working feature because it was not specified officially seems like the C approach of blaming the programmer for relying on what wasn't specified as reliable and not like Rust's stability story. |
This comment has been minimized.
This comment has been minimized.
|
As for it being just a lint: Either the lint is the first step towards breaking it, in which case it's not just a lint, or the existing stable behavior is going to continue to work in which case the lint would uselessly bother programmers on mainstream platforms. A lint that warns all programmers that their FFI code might not link with C code produced on some niche platform that Rust doesn't support yet would be a gross misbalancing of presently relevant mainstream needs vs. potential future niche concerns. |
This comment has been minimized.
This comment has been minimized.
|
@hsivonen this PR is only enacting the existing policy on this issue, which is that bool has an unspecified ABI. I think you should better talk to the lang team to get the policy specified. This would be the best outcome, and then this PR can be closed. |
This comment has been minimized.
This comment has been minimized.
|
What's the right place to discuss the policy? |
This comment has been minimized.
This comment has been minimized.
I posted to the internals forum. |
This comment has been minimized.
This comment has been minimized.
|
@hsivonen thanks for the post! |
michaelwoerister
added
T-compiler
and removed
T-compiler
labels
Nov 30, 2017
This comment has been minimized.
This comment has been minimized.
|
This is being discussed in the internals thread and needs more research. |
nagisa
referenced this pull request
Dec 11, 2017
Closed
Want a compiler warning if I repr(C) a bool #1982
kennytm
added
S-waiting-on-team
and removed
S-waiting-on-team
labels
Dec 20, 2017
kennytm
removed
the
S-waiting-on-team
label
Jan 10, 2018
This comment has been minimized.
This comment has been minimized.
This is a vague question -- what does "take values other than" mean? As others have explained, the standard is rather strict about what values a C program may get when converting or type-punning. But what bit patterns are actually stored in memory or registers is a different matter, because the standard does not specify the ABI, just program behavior (see also this post by ubsan). For example, None of this necessarily has to matter for Rust, if none of the platforms we care about do this (just as we don't support platforms where a byte isn't 8 bit), but it's important to remember that for our purposes we're interested in ABIs, which are not part of the language standard. |
This comment has been minimized.
This comment has been minimized.
|
@cuviper: Thank you! Great to see that there aren't problems on platforms that Rust already supports. (As for @whitequark: Do I understand correctly that 1) TI C54x/C55x are supported neither by GCC nor clang and 2) TI C54x/C55x have been superseded by C6x, which is supported by GCC and can address 8-bit bytes? |
This comment has been minimized.
This comment has been minimized.
|
regarding architectures that don't support byte level memory accesses, those have far bigger problems supporting Rust (or C++11 for that matter) than the size of |
This comment has been minimized.
This comment has been minimized.
|
Just to clarify: do we know of any cases where C++ |
This comment has been minimized.
This comment has been minimized.
|
FWIW, in the Itanium C++ ABI (used by many targets), 2.2 POD Data Types says:
|
This comment has been minimized.
This comment has been minimized.
|
@rfcbot fcp close Based on the survey done over the last few days, I propose to close this PR (which adds a lint based on the fact that
|
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Jan 22, 2018
•
|
Team member @withoutboats has proposed to close this. The next step is review by the rest of the tagged teams:
No concerns currently listed. Once these reviewers reach consensus, this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
rfcbot
added
the
proposed-final-comment-period
label
Jan 22, 2018
This comment has been minimized.
This comment has been minimized.
|
Why that way around and not the alternative? (Specify how bool currently behaves, and document that this matches _Bool on all platforms we support) |
This comment has been minimized.
This comment has been minimized.
People could come to the conclusion that they need a |
This comment has been minimized.
This comment has been minimized.
|
@withoutboats do I understand you correctly that this "close" FCP also functions as a "merge" FCP for #46156 ? |
This comment has been minimized.
This comment has been minimized.
|
I think we should merge that PR and also somewhere (the reference?) clarify precisely that it has the same representation as |
This comment has been minimized.
This comment has been minimized.
|
@withoutboats agreed; I was going to propose the same. @cuviper thanks, just what I wanted to know |
nikomatsakis
removed
the
I-nominated
label
Jan 25, 2018
This comment has been minimized.
This comment has been minimized.
|
friendly ping @jseyfried , your mark is missing. |
This comment has been minimized.
This comment has been minimized.
|
I took the libery of tagging for @jseyfried |
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Feb 1, 2018
|
|
rfcbot
added
final-comment-period
and removed
proposed-final-comment-period
labels
Feb 1, 2018
This comment has been minimized.
This comment has been minimized.
|
Closing in favour of #46156 |
est31 commentedNov 21, 2017
The ABI of bool is reserved, see these links:
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...