Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp709552pxm; Fri, 25 Feb 2022 17:56:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJxZXNwYkrwI7gdPuWwBoQPjpjiFtU+FT7CZLpwg8SePJGwqYPlD3nX4PYUDozGAnbj9pmPZ X-Received: by 2002:a17:902:da88:b0:150:f47:24ac with SMTP id j8-20020a170902da8800b001500f4724acmr10024106plx.73.1645840616040; Fri, 25 Feb 2022 17:56:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645840616; cv=none; d=google.com; s=arc-20160816; b=LKidziGmYWd+0KC9NNKBeSYNgPwIlrDjGwjEpvyJNsASrp4PCMr+/ttOb215d8dIbF Xw9muLnQGy116eY5VIaVzo42zAWJST84gKk3MatktqJGJ57ekQafKj2vUk3v16HJD3QI NYPsdjS4BkSpDTcJ+wMKqY59VwckhzkqEgbJXZhdj9hhsTvCqtIgwkfN2GW2fk/sqbNY K3hySUtKilSghznIiHM/xgWmejU3M4DfxatvQGIfo1aanwsxVRZ+25Um00teateX9DBE yM0itFFiP6QraUBFos3ZPUTP5Qr2NGaoFSoOzoaM0PdIM/n+k0Uvl3YX3+sE++PzvAX8 8C1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=WgPj5dwAYQV+V7+qsCDc+dal/QDoyfOr6ggGaVsZBDs=; b=L6r3r42FN9YQKmCYZa92iSSOVYFt/YchKb5tUAoAzhqERtrp9m4e/Tk8O6RuF6Czwa oYyvSY1zXDAdH6mlcUJidGZmGgYW9HWoUlZlR/hCXhAU2X3zsmgq0AuJphxXWudP9Sy2 iMUlaZ5SxDiiDfOzeOvJN/DLhi+cDd4QgF3Pmll8VMvoQNDtnHdMicsM9ZTvySh+ZUOY RGHyf6ctR6UdJWM2rbwoc+ulwcenbe6gwZPdMWJGZLIYbrLg765boZxwLTu/YI/EVpBk aZPdgCYFDGNOE08U5+XjVcw+NifpPfMjiA0/UazIiW/LyqbIFrJXzFP4hE/36yrk74Mk UwJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=nLyJE8Ck; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id cm20-20020a17090afa1400b001bc9fa6fae4si3233149pjb.117.2022.02.25.17.56.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Feb 2022 17:56:56 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=nLyJE8Ck; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B86DD286B71; Fri, 25 Feb 2022 17:40:32 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241182AbiBZBKk (ORCPT + 99 others); Fri, 25 Feb 2022 20:10:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241069AbiBZBKj (ORCPT ); Fri, 25 Feb 2022 20:10:39 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2FEB1CC7F5 for ; Fri, 25 Feb 2022 17:10:05 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8D7F661DFC for ; Sat, 26 Feb 2022 01:10:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8D40C340E7; Sat, 26 Feb 2022 01:10:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1645837804; bh=kg0FEgqg2RbTbd4/G8UmAfj8jgJTKH9dc0ETYajXWGE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=nLyJE8CkzO6RT7zL90b31sQRzCsqCsr16nYJDGLDEJ+oqkFw5uLAHV3x21H1hvsGk WtmN/nKTTFVbm7qJGI54/SUb3fm/5g/0nOcARqnPAytFxZcbHU9X1LsGUg4CehkcpG xdjpR0n81fsotdQncJjxyVERHjgDEBwUinQgUq+0= Date: Fri, 25 Feb 2022 17:10:04 -0800 From: Andrew Morton To: Alexey Dobriyan Cc: linux-kernel@vger.kernel.org, David Laight Subject: Re: [PATCH] Drop -Wdeclaration-after-statement Message-Id: <20220225171004.edfda47af82ae98ef1c18b9d@linux-foundation.org> In-Reply-To: References: X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 25 Feb 2022 11:15:58 +0300 Alexey Dobriyan wrote: > Putting declarations before statement is relict of single pass compiler > era. It was necessary to allocate stack slots before generating code. > > Recently added static_assert() is a declaration. -Wdeclaration-after-statement > prevents its placement anywhere in the code for no reason. > > Placing variable declarations in the beginning of the block increases > variable "LOC lifetime" so to speak and chances that it will be misused. > This is very low probability bug but still. Declaring variables right > before first use will make "LOC lifetime" smaller. > > { > int x; > [x is misused due to a typo] > f(x); // first correct use > } > > vs > > { > [can't misuse undeclared variable] > int x; > f(x); // first correct use > } > Oh man. I so wish you'd cc'ed Linus on this one so we could admire his reaction.