On Sun, 30 Mar 2025 15:07:36 GMT, SendaoYan <s...@openjdk.org> wrote:
> Hi all, > File src/java.base/share/native/libjli/java.c compile error: control reaches > end of non-void function [-Werror=return-type] with gcc options > -fsanitize=address -O0. The function int JavaMain(void* _args) in this file > will execute return ret in LEAVE() macro, but gcc with -O0 is not smart > enough to recognized that the function already has return statement before at > the end of function. It's a gcc bug which has been recorded by > [80959](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80959), and below code > snippet can demonstrate the gcc bug. I think we should disable return-type > gcc warning for java.c file before the gcc bug has been fixed. Risk is low. > > >> cat java.c > char a() { > return 0; > int b; > if (a(&b)) > return 0; > } > >> gcc -O0 -Wall -Wextra -Werror -O0 -c java.c -fsanitize=address > java.c: In function ‘a’: > java.c:6:1: error: control reaches end of non-void function > [-Werror=return-type] > 6 | } > | ^ > cc1: all warnings being treated as errors This pull request has now been integrated. Changeset: 9076673d Author: SendaoYan <s...@openjdk.org> URL: https://git.openjdk.org/jdk/commit/9076673d7df3c20bdb6e7fdf253030bc19a3d9dc Stats: 7 lines in 1 file changed: 7 ins; 0 del; 0 mod 8304674: File java.c compile error with -fsanitize=address -O0 Reviewed-by: ihse, jwaters ------------- PR: https://git.openjdk.org/jdk/pull/24318