RFR: 8062808: Turn on the -Wreturn-type warning
Kim Barrett
kim.barrett at oracle.com
Wed Nov 5 18:34:45 UTC 2014
On Nov 5, 2014, at 7:22 AM, Stefan Karlsson <stefan.karlsson at oracle.com> wrote:
>
> Hi all,
>
> I propose that we turn on the -Wreturn-type warning when compiling HotSpot with GCC.
>
> This will help us catch missing return statements earlier in the development cycle.
>
> http://cr.openjdk.java.net/~stefank/8062808/webrev.01/
> https://bugs.openjdk.java.net/browse/JDK-8062808
I’ve only skimmed this and not really reviewed, but I really dislike insertion of purportedly unreachable “return” statements to silence compiler warnings. I have a similar dislike for “if (check for bad case) { non-returning error processing } /* no else */ …” to disable such warnings by avoid an apparent terminating control flow w/o return at the end of the error processing. There’s got to be a better way…
I know that gcc/clang/MS all have annotation mechanism to mark code unreachable or functions as no-return. I’d rather see something like that added and used before we turn on -Wreturn-type, rather than littering / contorting code to avoid that warning. And compilers may generate better code sometimes when such are used.
And I say that having just last week wasted half a day debugging what turned out to be a small refactoring that left a code path without a return.
More information about the hotspot-dev
mailing list