Skip to content
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

gcc: fix uninitialized constructor warnings #8979

Merged

Conversation

jeffro256
Copy link
Contributor

No description provided.

@@ -77,15 +77,15 @@ namespace cryptonote
// outputs <= HF_VERSION_VIEW_TAGS
struct txout_to_key
{
txout_to_key() { }
txout_to_key() = default;
Copy link
Contributor

Choose a reason for hiding this comment

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

From cppreference.com under "implicitly-defined default constructor":

it has the same effect as a user-defined constructor with empty body and empty initializer list.

So this should be the same as existing code? Or is that the intent?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it should... I looked into it a bit more and I'm convinced that there's a bug with my version of g++ or maybe there's some obscure undefined behavior that is triggered in the verRctNonSemanticsSimple.serializable_sig_changes unit test. Either way, changing a ._push_back({}) to a ._emplace_back() fixed the warning which was generating pages and pages of garbage messages.

@jeffro256 jeffro256 force-pushed the bc_and_pool_unit_warning branch from 52ae338 to 414847c Compare September 11, 2023 07:24
@jeffro256
Copy link
Contributor Author

@UkoeHB latest commit also fixes the Microsoft C++ ABI -Wmismatched-tags warning you mentioned.

@@ -217,8 +217,7 @@ namespace rct {
rct::keyV L, R;
rct::key a, b, t;

Bulletproof():
A({}), S({}), T1({}), T2({}), taux({}), mu({}), a({}), b({}), t({}) {}
Bulletproof() = default;
Copy link
Contributor

Choose a reason for hiding this comment

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

This changes the behavior, and now the keys are not initialized to zero (except for V) if Bulletproof is default constructed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why would they not be initialized to zero? rct::key is a class type with no user provided constructor, and the default constructor of Bulletproof will call the implicit default constructor of rct::key, which will zero out the bytes[32] array.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@vtnerd can you also confirm this is resolved?

Copy link
Contributor

Choose a reason for hiding this comment

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

The default constructor does default initialization, not value initialization.

Copy link
Contributor

Choose a reason for hiding this comment

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

@selsta the problem is not resolved

Copy link
Contributor

Choose a reason for hiding this comment

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

https://godbolt.org/z/rMhd75PEn notice that there is no zero-initialization in the ASM.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, I was mixing up default initialization and value initialization

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Latest commit fixes that

@jeffro256 jeffro256 force-pushed the bc_and_pool_unit_warning branch from 414847c to 80b5bf8 Compare October 16, 2023 21:48
@luigi1111 luigi1111 merged commit a87f2bd into monero-project:master Nov 6, 2023
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants