-
Notifications
You must be signed in to change notification settings - Fork 38.8k
script: Disallow silent bool -> CScript conversion #18621
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
Conversation
|
ACK 88884ee |
|
ACK 88884ee. |
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
|
ACK 88884ee
More generally I think we should err on the safe side and only allow implicit conversions via explicit opt-in (instead of disallowing via explicit opt-out) :) |
jb55
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 88884ee
ryanofsky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review ACK 88884ee
I think it's not possible for just marking a constructor explicit to change which overload a compiler chooses like sipa was speculating about in https://github.com/bitcoin/bitcoin/pull/18612/files#r407269834 (assuming no sfinae overloads). But might be worth verifying this PR doesn't change compiler output.
I get the same bin with gcc/clang on O2 |
|
@ryanofsky FWIW, that is not true in general. The following code #include <stdio.h>
struct A { };
struct B : public A { };
struct C {
C(const A&) {printf("A\n");}
C(const B&) {printf("B\n");}
};
int main(void) {
const B objb = B();
const C objc = objb;
return 0;
}will print
|
|
utACK 88884ee |
Thanks, makes sense! I was thinking implicit constructor conversions would be pretty low in precedence but it makes sense derived-to-base conversions are lower |
88884ee script: Disallow silent bool -> CScript conversion (MarcoFalke) Pull request description: Makes nonsensical stuff like `ScriptToAsmStr(false,false);` a compile failure ACKs for top commit: practicalswift: ACK 88884ee laanwj: ACK 88884ee promag: ACK 88884ee. instagibbs: utACK 88884ee jb55: ACK 88884ee ryanofsky: Code review ACK 88884ee Tree-SHA512: 419d79c03b44a979c061b0540662928251ad68d53e65996bf370bb55ed1526ac7a22710cb7536c9954db5fec07bc312884bf8828f97a4ba180a5b07969a17f54
Summary: > Makes nonsensical stuff like ScriptToAsmStr(false,false); a compile failure This is a backport of Core [[bitcoin/bitcoin#18621 | PR18621]] Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D8935
88884ee script: Disallow silent bool -> CScript conversion (MarcoFalke) Pull request description: Makes nonsensical stuff like `ScriptToAsmStr(false,false);` a compile failure ACKs for top commit: practicalswift: ACK 88884ee laanwj: ACK 88884ee promag: ACK 88884ee. instagibbs: utACK 88884ee jb55: ACK 88884ee ryanofsky: Code review ACK 88884ee Tree-SHA512: 419d79c03b44a979c061b0540662928251ad68d53e65996bf370bb55ed1526ac7a22710cb7536c9954db5fec07bc312884bf8828f97a4ba180a5b07969a17f54
88884ee script: Disallow silent bool -> CScript conversion (MarcoFalke) Pull request description: Makes nonsensical stuff like `ScriptToAsmStr(false,false);` a compile failure ACKs for top commit: practicalswift: ACK 88884ee laanwj: ACK 88884ee promag: ACK 88884ee. instagibbs: utACK 88884ee jb55: ACK 88884ee ryanofsky: Code review ACK 88884ee Tree-SHA512: 419d79c03b44a979c061b0540662928251ad68d53e65996bf370bb55ed1526ac7a22710cb7536c9954db5fec07bc312884bf8828f97a4ba180a5b07969a17f54
Makes nonsensical stuff like
ScriptToAsmStr(false,false);a compile failure