Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libutil/hash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ Hash adl_serializer<Hash>::from_json(const json & json, const ExperimentalFeatur
auto & obj = getObject(json);
auto algo = parseHashAlgo(getString(valueAt(obj, "algorithm")), xpSettings);
auto format = parseHashFormat(getString(valueAt(obj, "format")));
auto & hashS = getString(valueAt(obj, "hash"));
Copy link
Contributor

Choose a reason for hiding this comment

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

Here it's fine actually. The warning is a false-positive caused by the second argument being a temporary std::string that dies at the end of the full expression. I think this is an instance of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114220.

Copy link
Member

Choose a reason for hiding this comment

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

I will try to avoid that by fixing valueAt though.

Copy link
Contributor

Choose a reason for hiding this comment

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

We can annotate it with [[gnu::no_dangle]] to silence the warning and remove the overload that takes a json && to make it fool-proof.

auto hashS = getString(valueAt(obj, "hash"));
return Hash::parseExplicitFormatUnprefixed(hashS, algo, format, xpSettings);
}

Expand Down
Loading