Skip to content

[kernel 3d/n] Misc ChainstateManager::Options fixups - #25607

Merged
maflcko merged 2 commits into
bitcoin:masterfrom
dongcarl:2022-07-kernel-fix-csmopts
Jul 14, 2022
Merged

maflcko merged 2 commits into
bitcoin:masterfrom
dongcarl:2022-07-kernel-fix-csmopts

Conversation

@dongcarl

@dongcarl dongcarl commented Jul 13, 2022 •

Copy link
Copy Markdown
Contributor

This is part of the libbitcoinkernel project: #24303, https://github.com/bitcoin/bitcoin/projects/18

This PR is NOT dependent on any other PRs.


Places ChainstateManager::Options into the kernel:: namespace and use designated initializers for construction.

@dongcarl

Copy link
Copy Markdown
Contributor Author

@MarcoFalke wondering if you know why the Desig usages are not working here? https://cirrus-ci.com/task/6347551300386816?logs=ci#L2321

init.cpp does #include <util/designator.h>

@maflcko

maflcko commented Jul 14, 2022

Copy link
Copy Markdown
Member

You'll need to rebase 😅

dongcarl added 2 commits July 14, 2022 08:27
It should have been there in the first place.
This wasn't available at the time when ChainstateManager::Options was
introduced but is helpful to be explicit and ensure correctness.
@dongcarl
dongcarl force-pushed the 2022-07-kernel-fix-csmopts branch from 5172135 to ce8b0f9 Compare July 14, 2022 12:36
@dongcarl

Copy link
Copy Markdown
Contributor Author

@ryanofsky ryanofsky left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review ACK ce8b0f9

I didn't realize Desig(field_name) compiled to nothing on certain platforms. That seems like it was dangerous because code might appear to be initializing one field, but actually be initializing another if fields were not in order. Unless maybe field order was enforced through CI. Anyway glad that is gone now.

@maflcko

maflcko commented Jul 14, 2022

Copy link
Copy Markdown
Member

Yes, it was enforced on every platform except msvc.

@maflcko
maflcko merged commit 02ede4f into bitcoin:master Jul 14, 2022
@ryanofsky

Copy link
Copy Markdown
Contributor

Yes, it was enforced on every platform except msvc.

Thanks, I didn't realize out of order designated initializers were actually forbidden by the language.

@ryanofsky

Copy link
Copy Markdown
Contributor

Thanks, I didn't realize out of order designated initializers were actually forbidden by the language.

Though if skipping a field was allowed this still could have been bad.

@maflcko

maflcko commented Jul 14, 2022

Copy link
Copy Markdown
Member

Skipping is allowed, and seems no worse than omission of "trailing" fields

@ryanofsky

Copy link
Copy Markdown
Contributor

Wouldn't this assign (1, 2, 0) on msvc and (1, 0, 2) on other platforms?

struct S {
   int a;
   int b;
   int c;
};

S s{
  Desig(a) 1,
  Desig(c) 2,
};

@maflcko

maflcko commented Jul 14, 2022

Copy link
Copy Markdown
Member

Yes (oops)

@bitcoin bitcoin locked and limited conversation to collaborators Jul 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

Status: Done or Closed or Rethinking

Development

Successfully merging this pull request may close these issues.

3 participants