public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/106992] New: aarch64: Unexpected maybe-uninitialized warning when compiling fdlibm
@ 2022-09-21 5:45 shqking at gmail dot com
2022-09-21 9:14 ` [Bug tree-optimization/106992] [12/13 Regression] " rguenth at gcc dot gnu.org
2023-05-08 12:25 ` [Bug tree-optimization/106992] [12/13/14 " rguenth at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: shqking at gmail dot com @ 2022-09-21 5:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106992
Bug ID: 106992
Summary: aarch64: Unexpected maybe-uninitialized warning when
compiling fdlibm
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: shqking at gmail dot com
Target Milestone: ---
Unexpected "maybe-uninitialized" warning was emitted when compiling fdlibm
library on Ubuntu 22.04 && AArch64 platform with GCC-12 and GCC-13.
How to reproduce it?
```
wget https://netlib.org/fdlibm/fdlibm.h
wget https://netlib.org/fdlibm/k_rem_pio2.c
gcc -Wall -Wextra -Werror -O2 -std=c11 -fno-strict-aliasing -c k_rem_pio2.c
```
The following warning would be produced.
```
k_rem_pio2.c: In function '__kernel_rem_pio2':
k_rem_pio2.c:188:13: error: this 'for' clause does not guard...
[-Werror=misleading-indentation]
188 | for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; q[i] = fw;
| ^~~
k_rem_pio2.c:188:61: note: ...this statement, but the latter is misleadingly
indented as if it were guarded by the 'for'
188 | for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; q[i] = fw;
| ^
k_rem_pio2.c:293:24: error: 'fq' may be used uninitialized
[-Werror=maybe-uninitialized]
293 | fw = fq[0]-fw;
| ~~^~~
k_rem_pio2.c:171:27: note: 'fq' declared here
171 | double z,fw,f[20],fq[20],q[20];
| ^~
k_rem_pio2.c:293:24: error: 'fq' may be used uninitialized
[-Werror=maybe-uninitialized]
293 | fw = fq[0]-fw;
| ~~^~~
k_rem_pio2.c:171:27: note: 'fq' declared here
171 | double z,fw,f[20],fq[20],q[20];
| ^~
cc1: all warnings being treated as errors
```
Note-1: I think it's a false positive because 1) array fq[] is initialized by
the for-stmt at line 276. Elements at index 0 to index "jz" are initialized. 2)
"jz" should be a non-negative value from the comment at line 87.
Note-2: No warning is produced on Ubuntu 22.04 && x86 platform.
Note-3: Known to work: gcc-11. Known to fail: gcc-12.0.1, 12.1.0, 12.2.0,
13.0.0.
Note-4: I filed an example with the C case I mentioned, i.e. k_rem_pio2.c,
after the pre-processing. See https://godbolt.org/z/Ph6r7vWeP. You may try
different GCC versions and x86/aarch64 backends there.
Note-5: It's worth noting that GCC at x86 platform would also produce this
waring message if we remove the option "-fno-strict-aliasing".
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/106992] [12/13 Regression] aarch64: Unexpected maybe-uninitialized warning when compiling fdlibm
2022-09-21 5:45 [Bug c/106992] New: aarch64: Unexpected maybe-uninitialized warning when compiling fdlibm shqking at gmail dot com
@ 2022-09-21 9:14 ` rguenth at gcc dot gnu.org
2023-05-08 12:25 ` [Bug tree-optimization/106992] [12/13/14 " rguenth at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-09-21 9:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106992
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target|aarch64 |aarch64, x86_64-*-*
Ever confirmed|0 |1
Last reconfirmed| |2022-09-21
Status|UNCONFIRMED |NEW
Target Milestone|--- |12.3
Blocks| |24639
Priority|P3 |P2
Summary|aarch64: Unexpected |[12/13 Regression] aarch64:
|maybe-uninitialized warning |Unexpected
|when compiling fdlibm |maybe-uninitialized warning
| |when compiling fdlibm
CC| |rguenth at gcc dot gnu.org
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed without -fno-strict-aliasing and with -fno-tree-vectorize
-fno-strict-aliasing on x86_64.
It's a bit odd - I traced walk_aliased_vdefs and indeed it didn't come along
a definition of fq. We diagnose a PRE hoisted fq[0] but even with
-fno-tree-pre -fno-code-hoisting we diagnose that.
-fno-thread-jumps avoids the diagnostic. The reference we diagnose is
introduced by thread2:
k_rem_pio2.c.195t.thread2: _508 = fq[0];
This case is
jump thread: (80, 136) incoming edge; (88, 90) normal (90, 94) nocopy;
<bb 80> [local count: 437174]:
<L145>:
if (jz_117 >= 0)
goto <bb 86>; [89.00%]
else
goto <bb 88>; [11.00%]
<bb 88> [local count: 437174]:
# fw_363 = PHI <fw_260(87), 0.0(80)>
if (ih_111 != 0)
goto <bb 90>; [50.00%]
else
goto <bb 89>; [50.00%]
<bb 90> [local count: 218587]:
iftmp.2_253 = -fw_363;
*y_237(D) = iftmp.2_253;
_85 = fq[0];
fw_255 = _85 - fw_363;
if (jz_117 > 0)
goto <bb 91>; [89.00%]
else
goto <bb 94>; [11.00%]
so it might be that we somehow thread a jz < 0 case (which would skip
the init loop) but I still can't see how ...
I've used
-Wall -O2 -std=c11 k_rem_pio2.c -fno-tree-vectorize -fno-strict-aliasing
-fno-code-hoisting -fno-tree-pre
for the above.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24639
[Bug 24639] [meta-bug] bug to track all Wuninitialized issues
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/106992] [12/13/14 Regression] aarch64: Unexpected maybe-uninitialized warning when compiling fdlibm
2022-09-21 5:45 [Bug c/106992] New: aarch64: Unexpected maybe-uninitialized warning when compiling fdlibm shqking at gmail dot com
2022-09-21 9:14 ` [Bug tree-optimization/106992] [12/13 Regression] " rguenth at gcc dot gnu.org
@ 2023-05-08 12:25 ` rguenth at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-05-08 12:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106992
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|12.3 |12.4
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 12.3 is being released, retargeting bugs to GCC 12.4.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-05-08 12:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-21 5:45 [Bug c/106992] New: aarch64: Unexpected maybe-uninitialized warning when compiling fdlibm shqking at gmail dot com
2022-09-21 9:14 ` [Bug tree-optimization/106992] [12/13 Regression] " rguenth at gcc dot gnu.org
2023-05-08 12:25 ` [Bug tree-optimization/106992] [12/13/14 " rguenth at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).