Skip to content

Annotate implicit fallthroughs #46

@fanquake

Description

@fanquake

Now that we've got -Wimplicit-fallthrough turned on in the Core repo, we'll see this output during builds including minisketch (I've put together a branch using the new build system changes, to test bitcoin/bitcoin#21859, here: https://github.com/fanquake/bitcoin/tree/minisketch_integration).

We turned this warning on in bitcoin/bitcoin#21430, and for at least leveldb, made use of it's FALLTHROUGH_INTENDED macro. See details here: https://github.com/bitcoin-core/leveldb/blob/f8ae182c1e5176d12e816fb2217ae33a5472fdd7/util/hash.cc#L11.

  CXX      minisketch/src/libminisketch_a-minisketch.o
minisketch/src/minisketch.cpp:104:13: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
            case 2:
            ^
minisketch/src/minisketch.cpp:104:13: note: insert '[[fallthrough]];' to silence this warning
            case 2:
            ^
            [[fallthrough]]; 
minisketch/src/minisketch.cpp:104:13: note: insert 'break;' to avoid fall-through
            case 2:
            ^
            break; 
minisketch/src/minisketch.cpp:107:13: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
            case 3:
            ^
minisketch/src/minisketch.cpp:107:13: note: insert '[[fallthrough]];' to silence this warning
            case 3:
            ^
            [[fallthrough]]; 
minisketch/src/minisketch.cpp:107:13: note: insert 'break;' to avoid fall-through
            case 3:
            ^
            break; 
minisketch/src/minisketch.cpp:110:13: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
            case 4:
            ^
minisketch/src/minisketch.cpp:110:13: note: insert '[[fallthrough]];' to silence this warning
            case 4:
            ^
            [[fallthrough]]; 
minisketch/src/minisketch.cpp:110:13: note: insert 'break;' to avoid fall-through
            case 4:
            ^
            break; 
minisketch/src/minisketch.cpp:113:13: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
            case 5:
            ^
minisketch/src/minisketch.cpp:113:13: note: insert '[[fallthrough]];' to silence this warning
            case 5:
            ^
            [[fallthrough]]; 
minisketch/src/minisketch.cpp:113:13: note: insert 'break;' to avoid fall-through
            case 5:
            ^
            break; 
minisketch/src/minisketch.cpp:116:13: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
            case 6:
            ^
minisketch/src/minisketch.cpp:116:13: note: insert '[[fallthrough]];' to silence this warning
            case 6:
            ^
            [[fallthrough]]; 
minisketch/src/minisketch.cpp:116:13: note: insert 'break;' to avoid fall-through
            case 6:
            ^
            break; 
minisketch/src/minisketch.cpp:119:13: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
            case 7:
            ^
minisketch/src/minisketch.cpp:119:13: note: insert '[[fallthrough]];' to silence this warning
            case 7:
            ^
            [[fallthrough]]; 
minisketch/src/minisketch.cpp:119:13: note: insert 'break;' to avoid fall-through
            case 7:
            ^
            break; 
minisketch/src/minisketch.cpp:122:13: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
            case 8:
            ^
minisketch/src/minisketch.cpp:122:13: note: insert '[[fallthrough]];' to silence this warning
            case 8:
            ^
            [[fallthrough]]; 
minisketch/src/minisketch.cpp:122:13: note: insert 'break;' to avoid fall-through
            case 8:
            ^
            break; 
minisketch/src/minisketch.cpp:125:13: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
            default:
            ^
minisketch/src/minisketch.cpp:125:13: note: insert '[[fallthrough]];' to silence this warning
            default:
            ^
            [[fallthrough]]; 
minisketch/src/minisketch.cpp:125:13: note: insert 'break;' to avoid fall-through
            default:
            ^
            break; 
8 warnings generated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions