Value: init "as" member to avoid -Wmaybe-uninitialized warning#10
Open
tbleher wants to merge 1 commit intouskr:masterfrom
Open
Value: init "as" member to avoid -Wmaybe-uninitialized warning#10tbleher wants to merge 1 commit intouskr:masterfrom
tbleher wants to merge 1 commit intouskr:masterfrom
Conversation
GCC (at least version 13.3) warns when moving a freshly constructed value,
since the "as" member is not initialized:
In constructor 'jsonrpc::Value::Value(jsonrpc::Value&&)',
inlined from 'jsonrpc::Response::Response(int32_t, std::string, jsonrpc::Value)' at jsonrpc-lean/response.h:27:13,
inlined from 'std::shared_ptr<jsonrpc::FormattedData> jsonrpc::Server::HandleRequest(const std::string&, const std::string&)' at jsonrpc-lean/server.h:74:17:
jsonrpc-lean/value.h:124:63: error: '<unnamed>.jsonrpc::Value::as' may be used uninitialized [-Werror=maybe-uninitialized]
124 | Value(Value&& other) noexcept : myType(other.myType), as(other.as) {
| ^~~~~~~~~~~~
jsonrpc-lean/server.h: In member function 'std::shared_ptr<jsonrpc::FormattedData> jsonrpc::Server::HandleRequest(const std::string&, const std::string&)':
jsonrpc-lean/server.h:74:62: note: '<anonymous>' declared here
74 | Response(ex.GetCode(), ex.GetString(), Value()).Write(*writer);
|
Fix this by initializing the member in the default constructor.
Author
|
@uskr I would appreciate if you could have a look at this patch :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GCC (at least version 13.3) warns when moving a freshly constructed value, since the "as" member is not initialized:
Fix this by initializing the member in the default constructor.