Repository navigation
util: Catch translation string errors at compile time - #30383
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsNo conflicts as of last run. |
|
Can be tested by looking at the CI failure, which should pop up soon, or by manually inserting the C++ code from the pull request description. |
CXX test/fuzz/fuzz-string.o
CXX libbitcoin_node_a-validation.o
test/fuzz/string.cpp:104:13: error: call to consteval function 'ConstevalStringLiteral::ConstevalStringLiteral' is not a constant expression
(void)_(random_string_1.c_str());
1 error generated.
validation.cpp:5750:30: error: call to consteval function 'ConstevalStringLiteral::ConstevalStringLiteral' is not a constant expression
return util::Error{_(reason)};
^
validation.cpp:5750:30: note: function parameter 'reason' with unknown value cannot be used in a constant expression
validation.cpp:5734:49: note: declared here
auto cleanup_bad_snapshot = [&](const char* reason) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
^
1 error generated. |
|
Concept ACK on the PR's goal. |
|
🚧 At least one of the CI tasks failed. Make sure to run all tests locally, according to the Possibly this is due to a silent merge conflict (the changes in this pull request being Leave a comment here, if you need help tracking down a confusing failure. |
|
Rebased to drop merged commit. Current CI failure is unrelated and can be ignored. |
Unrelated to this codebase, but I'd say this should be fixed upstream by doing |
The translation helper function
_()has many problems. For example, the following compiles:However, it is wrong, because none of the arguments passed to the function can be picked up by the translation tooling for transifex.
Fix all issues by enforcing only real string literals can be passed to the function.