public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/53802] New: Spurious 'may be used uninitialized' related to shifts
@ 2012-06-29 9:02 lukeocamden at gmail dot com
2012-06-29 9:57 ` [Bug tree-optimization/53802] " rguenth at gcc dot gnu.org
2014-02-03 18:31 ` lukeocamden at gmail dot com
0 siblings, 2 replies; 3+ messages in thread
From: lukeocamden at gmail dot com @ 2012-06-29 9:02 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53802
Bug #: 53802
Summary: Spurious 'may be used uninitialized' related to shifts
Classification: Unclassified
Product: gcc
Version: 4.7.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: lukeocamden@gmail.com
Trivial changes in the following program suppress the warning:
inline void foo(const unsigned char* mem_, unsigned int* value_)
{
unsigned int value = *mem_;
value <<= 8;
value |= *++mem_;
value <<= 8;
value |= *++mem_;
value <<= 8;
value |= *++mem_;
value <<= 8;
value |= *++mem_;
*value_ = value;
}
inline void bar(unsigned char* dest_, unsigned int value_)
{
if (!value_)
return;
dest_[0] = 0;
dest_[1] = value_ >> 24;
dest_[2] = value_ >> 16;
dest_[3] = value_ >> 8;
dest_[4] = value_;
}
int main()
{
for (unsigned int number = 0xFFFFFFFF; number; number >>= 1)
{
unsigned char buf[5];
bar(buf, number);
unsigned int val;
foo(buf, &val);
if (number != val)
return 0;
}
}
$ gcc main.cpp -O -Wall
main.cpp: In function 'int main()':
main.cpp:6:19: warning: '*((void*)& buf +1)' may be used uninitialized in this
function [-Wmaybe-uninitialized]
main.cpp:31:19: note: '*((void*)& buf +1)' was declared here
main.cpp:12:19: warning: '*((void*)& buf +4)' may be used uninitialized in this
function [-Wmaybe-uninitialized]
main.cpp:31:19: note: '*((void*)& buf +4)' was declared here
main.cpp:10:19: warning: '*((void*)& buf +3)' may be used uninitialized in this
function [-Wmaybe-uninitialized]
main.cpp:31:19: note: '*((void*)& buf +3)' was declared here
main.cpp:8:19: warning: '*((void*)& buf +2)' may be used uninitialized in this
function [-Wmaybe-uninitialized]
main.cpp:31:19: note: '*((void*)& buf +2)' was declared here
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/53802] Spurious 'may be used uninitialized' related to shifts
2012-06-29 9:02 [Bug tree-optimization/53802] New: Spurious 'may be used uninitialized' related to shifts lukeocamden at gmail dot com
@ 2012-06-29 9:57 ` rguenth at gcc dot gnu.org
2014-02-03 18:31 ` lukeocamden at gmail dot com
1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-06-29 9:57 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53802
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Status|UNCONFIRMED |NEW
Last reconfirmed| |2012-06-29
Ever Confirmed|0 |1
--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-06-29 09:57:17 UTC ---
Confirmed. Reason is a missed "jump-threading" (peeling off one iteration):
<bb 2>:
<bb 3>:
# number_59 = PHI <number_7(6), 4294967295(2)>
# buf$2_60 = PHI <buf$2_44(6), buf$2_51(D)(2)>
# buf$3_61 = PHI <buf$3_2(6), buf$3_52(D)(2)>
# buf$4_64 = PHI <buf$4_6(6), buf$4_53(D)(2)>
# buf$1_65 = PHI <buf$1_46(6), buf$1_50(D)(2)>
if (number_59 == 0)
goto <bb 5>;
else
goto <bb 4>;
<bb 4>:
D.2247_18 = number_59 >> 24;
buf$1_19 = (unsigned char) D.2247_18;
D.2245_20 = number_59 >> 16;
buf$2_21 = (unsigned char) D.2245_20;
D.2243_22 = number_59 >> 8;
buf$3_23 = (unsigned char) D.2243_22;
buf$4_24 = (unsigned char) number_59;
<bb 5>:
# buf$1_46 = PHI <buf$1_19(4), buf$1_65(3)>
# buf$2_44 = PHI <buf$2_21(4), buf$2_60(3)>
# buf$3_2 = PHI <buf$3_23(4), buf$3_61(3)>
# buf$4_6 = PHI <buf$4_24(4), buf$4_64(3)>
D.2257_29 = (unsigned int) buf$1_46;
so we decide there is a path from entry to BB 5 where buf$1_46 is not
initialized.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/53802] Spurious 'may be used uninitialized' related to shifts
2012-06-29 9:02 [Bug tree-optimization/53802] New: Spurious 'may be used uninitialized' related to shifts lukeocamden at gmail dot com
2012-06-29 9:57 ` [Bug tree-optimization/53802] " rguenth at gcc dot gnu.org
@ 2014-02-03 18:31 ` lukeocamden at gmail dot com
1 sibling, 0 replies; 3+ messages in thread
From: lukeocamden at gmail dot com @ 2014-02-03 18:31 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53802
lukeocamden at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #2 from lukeocamden at gmail dot com ---
Works fine with g++ (GCC) 4.9.0 20140202 (experimental)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-02-03 18:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-29 9:02 [Bug tree-optimization/53802] New: Spurious 'may be used uninitialized' related to shifts lukeocamden at gmail dot com
2012-06-29 9:57 ` [Bug tree-optimization/53802] " rguenth at gcc dot gnu.org
2014-02-03 18:31 ` lukeocamden at gmail dot 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).