From: Alexey Dobriyan <adobriyan@gmail.com>
To: David Laight <David.Laight@aculab.com>
Cc: "akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] Drop -Wdeclaration-after-statement
Date: Fri, 25 Feb 2022 20:24:47 +0300 [thread overview]
Message-ID: <YhkQ34tN8jEOR6SJ@localhost.localdomain> (raw)
In-Reply-To: <59387c6677af43c18d434b4f3c1e5430@AcuMS.aculab.com>
On Fri, Feb 25, 2022 at 10:01:23AM +0000, David Laight wrote:
> From: Alexey Dobriyan
> > Sent: 25 February 2022 08:16
> >
> > 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.
>
> That could enclose its declaration inside a block.
It could but why put useless characters on the screen?
> But then it wouldn't be usable at global scope (is it anyway?)
It is usable in global scope.
> > 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.
>
> NAK it makes it very hard for a human (some of us are) to find
> the declaration.
What?
Which editor are you using?
Shift+3 with selection highlighting in vim works just fine.
I don't believe Emacs doesn't have an equivalent.
> Indeed putting them anywhere other that the top of a function
> or the top of a very short code block makes them hard to find.
next prev parent reply other threads:[~2022-02-25 17:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-25 8:15 Alexey Dobriyan
2022-02-25 10:01 ` David Laight
2022-02-25 17:24 ` Alexey Dobriyan [this message]
2022-02-26 1:10 ` Andrew Morton
-- strict thread matches above, loose matches on Subject: below --
2019-03-10 13:35 Alexey Dobriyan
2019-03-12 0:38 ` Andrew Morton
2019-03-12 17:24 ` Alexey Dobriyan
2019-03-12 19:50 ` Andrew Morton
2019-03-12 20:18 ` Alexey Dobriyan
2019-03-12 20:53 ` Andrew Morton
2019-03-12 20:24 ` Alexey Dobriyan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YhkQ34tN8jEOR6SJ@localhost.localdomain \
--to=adobriyan@gmail.com \
--cc=David.Laight@aculab.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome