Skip to content

Fix -Wunreachable-code-loop-increment warning #19017

@fanquake

Description

@fanquake

In #19015 it's been suggested that we add some new compiler warnings to our build. Some of these, such as -Wunreachable-code-loop-increment, generate warnings. We'll likely want to fix these up if we're going to turn these warnings on.

init.cpp:969:5: warning: loop will run at most once (loop increment never executed) [-Wunreachable-code-loop-increment]
    for (const auto& arg : gArgs.GetUnsuitableSectionOnlyArgs()) {
    ^~~
1 warning generated.

bitcoin/src/init.cpp

Lines 968 to 972 in aa8d768

// on the command line or in this network's section of the config file.
std::string network = gArgs.GetChainName();
for (const auto& arg : gArgs.GetUnsuitableSectionOnlyArgs()) {
return InitError(strprintf(_("Config setting for %s only applied on %s network when in [%s] section."), arg, network, network));
}

If you want to build master, with -Wunreachable-code-loop-increment, you can use something like this:

./autogen.sh
./configure CXXFLAGS="-Wunreachable-code-loop-increment"
make check

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions