RFR: 8304674: File java.c compile error with -fsanitize=address -O0 [v3]
Julian Waters
jwaters at openjdk.org
Wed Apr 2 07:25:19 UTC 2025
On Tue, 1 Apr 2025 12:07:09 GMT, SendaoYan <syan at 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
>
> SendaoYan has updated the pull request incrementally with one additional commit since the last revision:
>
> add "#if defined(__GNUC__)" to fix windows build warning
I was going to suggest adding an && condition checking for ! __clang__ in the #if, but after some thinking I think it is not worth the trouble to add that. This looks good to go
-------------
Marked as reviewed by jwaters (Committer).
PR Review: https://git.openjdk.org/jdk/pull/24318#pullrequestreview-2734896635
More information about the build-dev
mailing list