On Mon, 25 Nov 2024 07:19:54 GMT, David Holmes <dhol...@openjdk.org> wrote:

> I think the sanitizer is just not smart enough to see that control flow can 
> never reach beyond the do/while loop of the macro.

I think you are right, the sanitizer of gcc is not smart enough at some 
situations. I found the similar code snippet which reduce from java.c cause gcc 
generate same compile error show as below. 
Acutally if the function of `int JavaMain(void* _args)` can be executed to 
`LEAVE()` macro, then control flow will never reach beyond the do/while loop of 
the macro, because the `return ret` statement in `LEAVE()` macro will always be 
executed. So add the `return ret` statement after `LEAVE()` macro will not take 
any effect, but this return statement will make the compile error disapper when 
configure with slowdebug and `--enable-asan` option.
So this PR seems a bit useful and no risk.


int a;
void c();
int d() {
  int b;
  c(&b);
  return a;
  if (0)
    ;
}



> gcc -Wall -Werror -c java.c -O0 -fsanitize=address
java.c: In function ā€˜d’:
java.c:9:1: error: control reaches end of non-void function 
[-Werror=return-type]
    9 | }
      | ^
cc1: all warnings being treated as errors
> gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/yansendao/software/gcc/gcc-14.2.0-binary/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: configure 
--prefix=/home/yansendao/git/tone-matrix-compiler/csmith/gcc-14.2.0/../gcc-14.2.0-binary
 --disable-multilib --enable-languages=c,c++,objc,obj-c++,fortran,lto
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.2.0 (GCC)

-------------

PR Comment: https://git.openjdk.org/jdk/pull/22355#issuecomment-2497997812

Reply via email to