Skip to content

Conversation

hebasto
Copy link
Member

@hebasto hebasto commented Mar 13, 2021

No description provided.

@DrahtBot
Copy link
Contributor

DrahtBot commented Mar 13, 2021

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

No conflicts as of last run.

@practicalswift
Copy link
Contributor

practicalswift commented Mar 15, 2021

cr ACK e95d14e: patch looks correct!

I've always been worried about introduction of bugs in our code due to unintentional fallthroughs. Thanks for reducing the number of things to worry about by one :)

As always: explicit is better than implicit! :)

Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

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

cr ACK e95d14e

didn't review the leveldb build change

@hebasto
Copy link
Member Author

hebasto commented Mar 15, 2021

Updated e95d14e -> 2f3436b (pr21430.01 -> pr21430.02, diff):

any reason to not enable the warning as well?

@MarcoFalke

didn't review the leveldb build change

// The FALLTHROUGH_INTENDED macro can be used to annotate implicit fall-through
// between switch labels. The real definition should be provided externally.

@practicalswift
Copy link
Contributor

practicalswift commented Mar 15, 2021

cr re-ACK 2f3436b

Consider submitting the tinyformat.h changes upstream too (https://github.com/c42f/tinyformat).

@hebasto
Copy link
Member Author

hebasto commented Apr 13, 2021

Rebased 2f3436b -> 5bc16d2 (pr21430.02 -> pr21430.03) due to the conflicts with #21610 and #21613.

@practicalswift
Copy link
Contributor

cr ACK 5bc16d2: patch looks correct

Thanks a lot for doing this @hebasto: the introduction of -Werror=implicit-fallthrough in our project combined with proper [[fallthrough]] annotations will most likely kill the "unintended fallthroughs" bug class for good.

Killing bug instances is cool, but killing entire bug classes is even cooler! :)

@hebasto
Copy link
Member Author

hebasto commented Jun 17, 2021

Rebased 5bc16d2 -> 45dc9f3 (pr21430.03 -> pr21430.04) due to the conflict with #22258.

@practicalswift
Copy link
Contributor

cr re-ACK 45dc9f3

Copy link
Member

@fanquake fanquake left a comment

Choose a reason for hiding this comment

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

Concept ACK.

@hebasto
Copy link
Member Author

hebasto commented Jul 3, 2021

Updated 45dc9f3 -> ebc36d9 (pr21430.04 -> pr21430.05):

@hebasto
Copy link
Member Author

hebasto commented Jul 5, 2021

Updated ebc36d9 -> 3c4c8e7 (pr21430.05 -> pr21430.06, diff):

Copy link
Member

@fanquake fanquake left a comment

Choose a reason for hiding this comment

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

ACK 3c4c8e7 - looks ok to me now. Checked that warnings occur in our code & leveldb by removing a [[fallthrough]] or FALLTHROUGH_INTENDED.

@theStack
Copy link
Contributor

Concept ACK

Copy link
Member

@jarolrod jarolrod left a comment

Choose a reason for hiding this comment

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

ACK 3c4c8e7

This is nice to be able to detect fallthroughs going forward. Appropriate since GCC 7 is the current minimum supported GCC.

Tested that the codebase itself will throw the warning by following the same step of removing one of the added [[fallthrough]] statements as outlined here: #21430 (review)

@hebasto
Copy link
Member Author

hebasto commented Jul 17, 2021

@practicalswift @MarcoFalke

Do you mind making another (final?) review?

Copy link
Contributor

@theStack theStack left a comment

Choose a reason for hiding this comment

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

ACK 3c4c8e7

Tested that removing an arbitrary [[fallthrough]] statment in the codebase leads to either a warning (default configuration) or an error (if configured with --enable-werror) with clang 11.0.1-2 (Debian bullseye/sid), e.g.:

hash.cpp:52:9: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
        case 2:
        ^
hash.cpp:52:9: note: insert '[[fallthrough]];' to silence this warning
        case 2:
        ^
        [[fallthrough]];
hash.cpp:52:9: note: insert 'break;' to avoid fall-through
        case 2:
        ^
        break;
1 error generated.

By the way, any reason we don't --enable-werror by default? Being on the cautious side would seem to be a more sane default to me.

@fanquake fanquake merged commit 6baabc4 into bitcoin:master Jul 18, 2021
@maflcko
Copy link
Member

maflcko commented Jul 18, 2021

By the way, any reason we don't --enable-werror by default? Being on the cautious side would seem to be a more sane default to me.

There might be unknown warnings in future releases of compilers that we are not aware of. Also, compilers might produce false warnings if they have bugs. So we only error on well tested and selected warnings.

@hebasto hebasto deleted the 210313-fall branch July 18, 2021 08:46
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jul 23, 2021
…flag

3c4c8e7 build: Add -Werror=implicit-fallthrough compile flag (Hennadii Stepanov)
014110c Use C++17 [[fallthrough]] attribute, and drop -Wno-implicit-fallthrough (Hennadii Stepanov)

Pull request description:

ACKs for top commit:
  fanquake:
    ACK 3c4c8e7 - looks ok to me now. Checked that warnings occur in our code & leveldb by removing a `[[fallthrough]]` or `FALLTHROUGH_INTENDED`.
  jarolrod:
    ACK 3c4c8e7
  theStack:
    ACK 3c4c8e7

Tree-SHA512: 4dce91f0f26b8a3de09bd92bb3d7e1995e078e3a8b3ff861c4fbf6c0b32b2327d063633b07b89c4aa94a1141d7f78d46d9d43ab8df865273e342693ad30645b6
gwillen pushed a commit to ElementsProject/elements that referenced this pull request Jun 1, 2022
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants