Sjors
commented at 9:32 AM on February 14, 2020:
member
I overlooked a missing return false in #17577 (review) and the warning only showed up on one Travis machine (warning: control reaches end of non-void function [-Wreturn-type]).
This PR promotes Wreturn-type to an error when configured with --enable-werror. I also added --enable-werror to the Travis machine that happened to catch this particular instance.
Sjors renamed this: build: add Wreturn-type to Werror flags, check on more Travis machines WIP build: add Wreturn-type to Werror flags, check on more Travis machines on Feb 14, 2020
Sjors
commented at 9:33 AM on February 14, 2020:
member
~(don't merge this yet, I need to drop the last commit 4294b2f which should produce the error)~
fanquake added the label Build system on Feb 14, 2020
build: add Wreturn-type to Werror flags
This is supported by GCC and Clang.
https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
https://clang.llvm.org/docs/DiagnosticsReference.html#wreturn-type
6ba617dbe2
ci: use --enable-werror on more hostsc98c26ee99
Sjors force-pushed on Feb 14, 2020
Sjors force-pushed on Feb 14, 2020
Sjors renamed this: WIP build: add Wreturn-type to Werror flags, check on more Travis machines build: add Wreturn-type to Werror flags, check on more Travis machines on Feb 14, 2020
vasild
commented at 10:39 AM on February 14, 2020:
member
-Wreturn-type is enabled by default (even without -Wall) in clang and gcc:
enum Color {
RED,
BLUE
};
bool isWarm(Color c) {
switch (c) {
case RED:
return true;
case BLUE:
return false;
}
}
bool isCold(Color c) {
if (c == BLUE) {
return true;
}
}
produces:
Clang 7.0.1, 8.0.1, 9.0.1 with no options, with just -Wall, with -Wall -Wreturn-type: only a warning for isCold(): warning: control may reach end of non-void function [-Wreturn-type].
GCC 9.2.0 with no options, with just -Wall, with -Wall -Wreturn-type: a warning for both functions: warning: control reaches end of non-void function [-Wreturn-type].
Clang is staying silent about isWarm() because it sees that all enumeration values are handled in the switch. If I remove the case BLUE:, then I get two warnings for isWarm():
warning: enumeration value 'BLUE' not handled in switch [-Wswitch]
warning: control may reach end of non-void function [-Wreturn-type]
That said, adding explicitly -Wreturn-type is unnecessary because it is enabled by default.
vasild
commented at 10:56 AM on February 14, 2020:
member
Ah! But we are using -Werror=whatever which selectively turns only some warnings into errors. Sorry for the noise above.
ACKc98c26e.
practicalswift
commented at 1:30 PM on February 14, 2020:
contributor
Thanks for working on this! I think we're currently somewhat underutilising the help we can get from compilers in the form of compiler diagnostics to prevent mistakes and this PR brings us in the right direction :)
ACKc98c26ee992f204b17bf17d271512b36c40ad8c5
If you have time please consider submitting a PR enabling the subset of compiler diagnostics discussed in #17344 that you think make sense. I would be glad to review such PRs, so don't hesitate to ping me in for review.
DrahtBot
commented at 1:41 PM on February 14, 2020:
member
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
Conflicts
Reviewers, this pull request conflicts with the following ones:
#18149 (build: change --enable-werror to enable -Werror by vasild)
#15112 (build: Optionally enable -Wzero-as-null-pointer-constant by Empact)
#14920 (Build: enable -Wdocumentation via isystem by Empact)
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
MarcoFalke referenced this in commit 33861a8367 on Feb 16, 2020
MarcoFalke merged this on Feb 16, 2020
MarcoFalke closed this on Feb 16, 2020
Sjors deleted the branch on Feb 16, 2020
kittywhiskers referenced this in commit 1038970b69 on Jun 17, 2021
kittywhiskers referenced this in commit c73d0740f1 on Jun 17, 2021
kittywhiskers referenced this in commit 49921dbdd8 on Jun 17, 2021
UdjinM6 referenced this in commit 988fa6a235 on Jun 23, 2021
This is a metadata mirror of the GitHub repository
bitcoin/bitcoin.
This site is not affiliated with GitHub.
Content is generated from a GitHub metadata backup.
generated: 2026-04-14 09:14 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me