From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10755 invoked by alias); 29 Jun 2012 09:02:40 -0000 Received: (qmail 10736 invoked by uid 22791); 29 Jun 2012 09:02:38 -0000 X-SWARE-Spam-Status: No, hits=-3.6 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 29 Jun 2012 09:02:26 +0000 From: "lukeocamden at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/53802] New: Spurious 'may be used uninitialized' related to shifts Date: Fri, 29 Jun 2012 09:02:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: lukeocamden at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-06/txt/msg01920.txt.bz2 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