JDK-8062808 : Turn on the -Wreturn-type warning
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 9
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2014-11-04
  • Updated: 2021-02-04
  • Resolved: 2014-11-12
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9 Other
8u261Fixed 9 b42Fixed openjdk7uFixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
I propose that we patch HotSpot and start compiling with the -Wreturn-type warning. This will help us catch missing return statements earlier in the development cycle.

From:
https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html

"-Wreturn-type
    Warn whenever a function is defined with a return type that defaults to int. Also warn about any return statement with no return value in a function whose return type is not void (falling off the end of the function body is considered returning without a value), and about a return statement with an expression in a function whose return type is void.

    For C++, a function without return type always produces a diagnostic message, even when -Wno-return-type is specified. The only exceptions are ���main��� and functions defined in system headers.

    This warning is enabled by -Wall. "
Comments
Fix Request (8u). This is the third of 3 issues: JDK-8030350, JDK-8036122, and JDK-8062808 (this one). Very low risk, adds compile time checking. Review approval: https://mail.openjdk.java.net/pipermail/jdk8u-dev/2020-October/012757.html
05-10-2020

[~aph] In my understanding, to get this patch backported, you need to backport JDK-8022263 , JDK-8141570, JDK-8030350 and JDK-8036122. the first two patches have been done. Do you get bandwidth to finish the last two? I just re-verify the my patch. It still can apply to jdk8u-dev/hotspot "almost" cleanly. Building succeeds with -Wreturn-type.
01-07-2020

According to this review thread this patch has not been reviewed yet. https://mail.openjdk.java.net/pipermail/jdk8u-dev/2019-August/010100.html Please only apply the jdk8u-fix-request label *after* it's been reviewed. Please then also note in the fix request comment who approved it and provide a link to the review thread. I'm removing the jdk8u-fix-request label until it's reviewed and there is a clear path forward. I see that JDK-8141570 has been integrated. It's not clear whether or not a review is required now.
07-01-2020

Fix request for 8u. we can almost apply it cleanly.I made a little bit changes. https://cr.openjdk.java.net/~xliu/8062808/webrev/
13-12-2019