From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6841 invoked by alias); 29 Nov 2007 15:49:04 -0000 Received: (qmail 6833 invoked by uid 22791); 29 Nov 2007 15:49:03 -0000 X-Spam-Check-By: sourceware.org Received: from el-out-1112.google.com (HELO el-out-1112.google.com) (209.85.162.181) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 29 Nov 2007 15:48:52 +0000 Received: by el-out-1112.google.com with SMTP id n30so840870elf for ; Thu, 29 Nov 2007 07:48:50 -0800 (PST) Received: by 10.142.111.14 with SMTP id j14mr1944990wfc.1196351329468; Thu, 29 Nov 2007 07:48:49 -0800 (PST) Received: by 10.70.54.17 with HTTP; Thu, 29 Nov 2007 07:48:49 -0800 (PST) Message-ID: <998d0e4a0711290748jb1c1441gc483e488443a6214@mail.gmail.com> Date: Thu, 29 Nov 2007 16:01:00 -0000 From: "J.C. Pizarro" To: "Mikael Vidstedt" , gcc-help@gcc.gnu.org Subject: Re: Missing warning about uninitialized variable. MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2007-11/txt/msg00394.txt.bz2 On 2007/11/29, Mikael Vidstedt wrote: > The following program may make use of an uninitialized variable (gurka): > > int > main(int argc, char* argv[]) > { > int gurka; > > if(argc == 10) { > gurka = 3; > } > > // gurka isn't necessarily initialized here... > printf("%d\n", gurka); > > return 0; > } > > GCC 4.0 will give a warning when this program is compiled with "-O > -Wall". GCC 4.1 and 4.2 do not give that warning. I haven't had the > possibility to try GCC 4.3. > > What say ye? > > Thanks, > Mikael It prints stochasticly random data too. gcc version 4.2.3 20071031 (prerelease) $ gcc -Wall -o foo foo.c foo.c: In function 'main': foo.c:11: warning: implicit declaration of function 'printf' foo.c:11: warning: incompatible implicit declaration of built-in function 'printf' $ for i in $(seq 1 5); do ./foo $(seq 1 10) ; done -1209020420 -1208291332 -1208422404 -1208803332 -1208823812 $ J.C.Pizarro