public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug middle-end/95681] New: False positive uninitialized variable usage in decNumberCompareTotalMag @ 2020-06-15 13:54 stefansf at linux dot ibm.com 2021-07-09 1:23 ` [Bug middle-end/95681] " trnsz at pobox dot com ` (3 more replies) 0 siblings, 4 replies; 5+ messages in thread From: stefansf at linux dot ibm.com @ 2020-06-15 13:54 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95681 Bug ID: 95681 Summary: False positive uninitialized variable usage in decNumberCompareTotalMag Product: gcc Version: 11.0 Status: UNCONFIRMED Keywords: build, diagnostic Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: stefansf at linux dot ibm.com Target Milestone: --- Target: s390 The following error/warning shows up on S/390 while bootstrapping: libdecnumber/decNumber.c: In function 'decNumberCompareTotalMag': libdecnumber/decNumber.c:953:14: error: '*(allocbufa).bits' may be used uninitialized [-Werror=maybe-uninitialized] 953 | a->bits&=~DECNEG; /* .. and clear the sign */ | ^~ libdecnumber/decNumber.c:967:14: error: '*(allocbufb).bits' may be used uninitialized [-Werror=maybe-uninitialized] 967 | b->bits&=~DECNEG; /* .. and clear the sign */ | ^~ The part of interest is: if (decNumberIsNegative(lhs)) { /* lhs<0 */ a=bufa; needbytes=sizeof(decNumber)+(D2U(lhs->digits)-1)*sizeof(Unit); if (needbytes>sizeof(bufa)) { /* need malloc space */ allocbufa=(decNumber *)malloc(needbytes); if (allocbufa==NULL) { /* hopeless -- abandon */ status|=DEC_Insufficient_storage; break;} a=allocbufa; /* use the allocated space */ } decNumberCopy(a, lhs); /* copy content */ a->bits&=~DECNEG; /* .. and clear the sign */ lhs=a; /* use copy from here on */ } While calling `decNumberCopy` variable `a` either points to `bufa` or to `allocbufa`. Since `bufa` and `allocbufa` are both allocated inside function `decNumberCompareTotalMag` and argument `lhs` is not changed, it is guaranteed that `a != lhs` holds prior call `decNumberCopy(a, lhs)`. Function `decNumberCopy` initializes `a->bits`, if `a != lhs` holds. Since this is the case here, no warning should be printed. Note, no warning is printed if `dest->bits=src->bits;` is shifted above `if (dest==src) return dest;` of function `decNumberCopy` which endorses that this is a false positive resulting from a wrong assumption that `a == lhs` may hold. Analogous for the second warning/error which speaks about variable `b`. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/95681] False positive uninitialized variable usage in decNumberCompareTotalMag 2020-06-15 13:54 [Bug middle-end/95681] New: False positive uninitialized variable usage in decNumberCompareTotalMag stefansf at linux dot ibm.com @ 2021-07-09 1:23 ` trnsz at pobox dot com 2021-07-09 17:47 ` msebor at gcc dot gnu.org ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: trnsz at pobox dot com @ 2021-07-09 1:23 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95681 --- Comment #1 from Jeffrey H. Johnson <trnsz at pobox dot com> --- Confirm this behavior and reached same analysis with gcc version 11.1.1 20210531 (Red Hat 11.1.1-3) on x86_64. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/95681] False positive uninitialized variable usage in decNumberCompareTotalMag 2020-06-15 13:54 [Bug middle-end/95681] New: False positive uninitialized variable usage in decNumberCompareTotalMag stefansf at linux dot ibm.com 2021-07-09 1:23 ` [Bug middle-end/95681] " trnsz at pobox dot com @ 2021-07-09 17:47 ` msebor at gcc dot gnu.org 2021-07-16 7:05 ` stefansf at linux dot ibm.com 2021-07-16 7:09 ` stefansf at linux dot ibm.com 3 siblings, 0 replies; 5+ messages in thread From: msebor at gcc dot gnu.org @ 2021-07-09 17:47 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95681 Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 CC| |msebor at gcc dot gnu.org Status|UNCONFIRMED |WAITING Last reconfirmed| |2021-07-09 --- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> --- Could you please reduce the warning to a standalone test case (or translation unit) and attach it to the report so that it can be more easily reproduced (with a cross-compiler) and analyzed? ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/95681] False positive uninitialized variable usage in decNumberCompareTotalMag 2020-06-15 13:54 [Bug middle-end/95681] New: False positive uninitialized variable usage in decNumberCompareTotalMag stefansf at linux dot ibm.com 2021-07-09 1:23 ` [Bug middle-end/95681] " trnsz at pobox dot com 2021-07-09 17:47 ` msebor at gcc dot gnu.org @ 2021-07-16 7:05 ` stefansf at linux dot ibm.com 2021-07-16 7:09 ` stefansf at linux dot ibm.com 3 siblings, 0 replies; 5+ messages in thread From: stefansf at linux dot ibm.com @ 2021-07-16 7:05 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95681 --- Comment #3 from Stefan Schulze Frielinghaus <stefansf at linux dot ibm.com> --- Created attachment 51160 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51160&action=edit Reduced program ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/95681] False positive uninitialized variable usage in decNumberCompareTotalMag 2020-06-15 13:54 [Bug middle-end/95681] New: False positive uninitialized variable usage in decNumberCompareTotalMag stefansf at linux dot ibm.com ` (2 preceding siblings ...) 2021-07-16 7:05 ` stefansf at linux dot ibm.com @ 2021-07-16 7:09 ` stefansf at linux dot ibm.com 3 siblings, 0 replies; 5+ messages in thread From: stefansf at linux dot ibm.com @ 2021-07-16 7:09 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95681 --- Comment #4 from Stefan Schulze Frielinghaus <stefansf at linux dot ibm.com> --- Running todays mainline (d97d71a1989) using options -O3 -Wall against the reduced program on x86 as well as s390x results in t.c: In function 'decNumberCompareTotalMag': t.c:55:14: warning: '*allocbufa.bits' may be used uninitialized [-Wmaybe-uninitialized] 55 | a->bits&=~0x80; | ^~ t.c:70:14: warning: '*allocbufb.bits' may be used uninitialized [-Wmaybe-uninitialized] 70 | b->bits&=~0x80; | ^~ ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-07-16 7:09 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-06-15 13:54 [Bug middle-end/95681] New: False positive uninitialized variable usage in decNumberCompareTotalMag stefansf at linux dot ibm.com 2021-07-09 1:23 ` [Bug middle-end/95681] " trnsz at pobox dot com 2021-07-09 17:47 ` msebor at gcc dot gnu.org 2021-07-16 7:05 ` stefansf at linux dot ibm.com 2021-07-16 7:09 ` stefansf at linux dot ibm.com
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).