Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756895AbcCCMtc (ORCPT ); Thu, 3 Mar 2016 07:49:32 -0500 Received: from smtprelay0068.hostedemail.com ([216.40.44.68]:37469 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755580AbcCCMta (ORCPT ); Thu, 3 Mar 2016 07:49:30 -0500 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::::,RULES_HIT:41:355:379:541:599:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1540:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:2894:3138:3139:3140:3141:3142:3352:3622:3865:3866:3867:3868:3871:3872:3874:4250:4321:4470:5007:6119:6120:6261:7875:7901:7904:10004:10400:10848:11026:11232:11658:11783:11914:12043:12438:12517:12519:12740:13069:13311:13357:13439:13894:14659:21080:21324:21326:30012:30054:30064:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: start15_354f1acf57924 X-Filterd-Recvd-Size: 2282 Message-ID: <1457009365.4044.115.camel@perches.com> Subject: Re: Q: why didn't GCC warn about this uninitialized variable? From: Joe Perches To: Ingo Molnar , =?ISO-8859-1?Q?M=E5ns_Rullg=E5rd?= Cc: Arnaldo Carvalho de Melo , Peter Zijlstra , Colin King , Ingo Molnar , linux-kernel@vger.kernel.org, Richard Henderson , Jakub Jelinek , Dan Carpenter Date: Thu, 03 Mar 2016 04:49:25 -0800 In-Reply-To: <20160303124319.GA8781@gmail.com> References: <1456923322-29697-1-git-send-email-colin.king@canonical.com> <20160302125901.GF6356@twins.programming.kicks-ass.net> <20160302130350.GO3604@kernel.org> <20160302132127.GG6356@twins.programming.kicks-ass.net> <20160302132323.GP3604@kernel.org> <20160303121944.GB2484@gmail.com> <20160303124319.GA8781@gmail.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.5-1ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 869 Lines: 18 On Thu, 2016-03-03 at 13:43 +0100, Ingo Molnar wrote: > it would be absolutely fantastic if one of these solutions existed on GCC:> > > ?- emit a warning if a structure is passed around uninitialized. A new GCC > ???__attribute__((struct_fully_initialized)) could be used to annotate extern > ???function arguments which fully initialize input arguments. > > ???(I'd personally migrate both tools/perf and kernel side code to use it, module > ????by module.) > > ?- or memset() to zero all on-stack structures that GCC cannot prove are > ???initialized fully. > > The first solution takes extra work on the source level, the latter takes extra? > runtime profiling to find where the extra memset()s matter to performance. Any of? > these would be fantastic tools for C robustness and security. Maybe memset any alignment padding between automatic variables too.