ScriptToAsmStr(false,false);
a compile failure
script: Disallow silent bool -> CScript conversion #18621
pull MarcoFalke wants to merge 1 commits into bitcoin:master from MarcoFalke:2004-scriptNoBool changing 1 files +1 −1-
MarcoFalke commented at 12:57 pm on April 13, 2020: memberMakes nonsensical stuff like
-
script: Disallow silent bool -> CScript conversion 88884ee8d8
-
laanwj commented at 1:02 pm on April 13, 2020: memberACK 88884ee8d8dcd5303b20e54801b03f9631959c76
-
DrahtBot added the label Consensus on Apr 13, 2020
-
promag commented at 1:57 pm on April 13, 2020: memberACK 88884ee8d8dcd5303b20e54801b03f9631959c76.
-
DrahtBot commented at 4:37 pm on April 13, 2020: member
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Conflicts
Reviewers, this pull request conflicts with the following ones:
- #18612 (script: Remove undocumented and unused operator+ by MarcoFalke)
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.
-
practicalswift commented at 5:11 pm on April 13, 2020: contributor
ACK 88884ee8d8dcd5303b20e54801b03f9631959c76
explicit
is better than implicit.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 approved
-
jb55 commented at 5:14 pm on April 13, 2020: memberACK 88884ee8d8dcd5303b20e54801b03f9631959c76
-
ryanofsky approved
-
ryanofsky commented at 5:26 pm on April 13, 2020: member
Code review ACK 88884ee8d8dcd5303b20e54801b03f9631959c76
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. -
MarcoFalke commented at 5:53 pm on April 13, 2020: member
But might be worth verifying this PR doesn’t change compiler output.
I get the same bin with gcc/clang on O2
-
sipa commented at 6:27 pm on April 13, 2020: member
@ryanofsky FWIW, that is not true in general.
The following code
0#include <stdio.h> 1 2struct A { }; 3struct B : public A { }; 4struct C { 5 C(const A&) {printf("A\n");} 6 C(const B&) {printf("B\n");} 7}; 8 9int main(void) { 10 const B objb = B(); 11 const C objc = objb; 12 13 return 0; 14}
will print
B
. When theC::C(const B&)
constructor is marked explicit, it printsA
. So it seems that:- Explicit constructors only match in explicit contexts.
- deleted functions/constructors match just as much as non-deleted ones.
- Among all matching functions the most specific one is chosen.
- If the most specific one is deleted, there is an error.
-
instagibbs commented at 5:22 pm on April 14, 2020: memberutACK 88884ee8d8dcd5303b20e54801b03f9631959c76
-
ryanofsky commented at 6:14 pm on April 14, 2020: member
@ryanofsky FWIW, that is not true in general.
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
-
fanquake merged this on Apr 15, 2020
-
fanquake closed this on Apr 15, 2020
-
MarcoFalke deleted the branch on Apr 15, 2020
-
sidhujag referenced this in commit 9376e7f339 on Apr 15, 2020
-
ComputerCraftr referenced this in commit 0d51754852 on Jun 10, 2020
-
Fabcien referenced this in commit 4f308eaa81 on Jan 18, 2021
-
PastaPastaPasta referenced this in commit a2c2ca980b on Jun 27, 2021
-
PastaPastaPasta referenced this in commit 0ab09c07c2 on Jun 28, 2021
-
PastaPastaPasta referenced this in commit 05384cd2c2 on Jun 29, 2021
-
PastaPastaPasta referenced this in commit b756c19fd0 on Jul 1, 2021
-
PastaPastaPasta referenced this in commit 49e93b17d2 on Jul 1, 2021
-
PastaPastaPasta referenced this in commit 71d4883643 on Jul 14, 2021
-
PastaPastaPasta referenced this in commit 7b74287215 on Jul 14, 2021
-
DrahtBot locked this on Feb 15, 2022
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-26 21:12 UTC
More mirrored repositories can be found on mirror.b10c.me