Details
Description
GCC 12 reports as following:
```
/home/ysuenaga/github-forked/jdk/src/java.base/share/native/libjli/java.c:1629:35: error: the comparison will always evaluate as 'false' for the pointer operand in 'arg + 2' must not be NULL [-Werror=address]
1629 | *nargv++ = ((arg + 2) == NULL) ? NULL : JLI_StringDup(arg + 2);
|
```
The code is here:
```
1625 /* Copy the VM arguments (i.e. prefixed with -J) */
1626 for (i = 0; i < jargc; i++) {
1627 const char *arg = jargv[i];
1628 if (arg[0] == '-' && arg[1] == 'J') {
1629 *nargv++ = ((arg + 2) == NULL) ? NULL : JLI_StringDup(a rg + 2);
1630 }
1631 }
```
It seems to be expected that `NULL` is set to new array for arguments if invalid parameter ( `-J` only) is passed.
However `NULL` in new array for arguments (`nargv`) means stop condition for argument processing in below:
```
1214 while ((arg = *argv) != 0 && *arg == '-') {
```
`jargv` in L1627 means builtin arguments which is defined by `JAVA_ARGS` or `EXTRA_JAVA_ARGS` macro. So it should be ignored and reported it in laucher trace log.
```
/home/ysuenaga/github-forked/jdk/src/java.base/share/native/libjli/java.c:1629:35: error: the comparison will always evaluate as 'false' for the pointer operand in 'arg + 2' must not be NULL [-Werror=address]
1629 | *nargv++ = ((arg + 2) == NULL) ? NULL : JLI_StringDup(arg + 2);
|
```
The code is here:
```
1625 /* Copy the VM arguments (i.e. prefixed with -J) */
1626 for (i = 0; i < jargc; i++) {
1627 const char *arg = jargv[i];
1628 if (arg[0] == '-' && arg[1] == 'J') {
1629 *nargv++ = ((arg + 2) == NULL) ? NULL : JLI_StringDup(a rg + 2);
1630 }
1631 }
```
It seems to be expected that `NULL` is set to new array for arguments if invalid parameter ( `-J` only) is passed.
However `NULL` in new array for arguments (`nargv`) means stop condition for argument processing in below:
```
1214 while ((arg = *argv) != 0 && *arg == '-') {
```
`jargv` in L1627 means builtin arguments which is defined by `JAVA_ARGS` or `EXTRA_JAVA_ARGS` macro. So it should be ignored and reported it in laucher trace log.
Attachments
Issue Links
- relates to
-
JDK-8286562 GCC 12 reports some compiler warnings
-
- Resolved
-