From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5863 invoked by alias); 18 Aug 2008 13:32:56 -0000 Received: (qmail 5680 invoked by uid 48); 18 Aug 2008 13:31:34 -0000 Date: Mon, 18 Aug 2008 13:32:00 -0000 Subject: [Bug c/37148] New: -Wunintialized fails in the face of conditional assignment. X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "thutt at vmware dot com" 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: 2008-08/txt/msg01265.txt.bz2 Although I demonstrated this using 4.1.2 on my host, it probably affects other versions as well. As the following code shows: gcc -c -O1 -Wall -Werror uninitialized-warning.c extern void called_function(unsigned p); extern unsigned g; void f0(unsigned parm) { unsigned v; if (parm == 0) { v = 4; } called_function(v); } void f1(unsigned parm) { unsigned v; if (parm == 0) { v = 4; } else { g = 0; } called_function(v); } void f2(unsigned parm) { unsigned v; called_function(v); } gcc does not produce the 'uninitialized' warning when the automatic variable is conditionally assigned. This gives a very bad false sense of security that the automatic variables are indeed initialized. -- Summary: -Wunintialized fails in the face of conditional assignment. Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: thutt at vmware dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37148