[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YhkQ34tN8jEOR6SJ@localhost.localdomain>
Date: Fri, 25 Feb 2022 20:24:47 +0300
From: Alexey Dobriyan <adobriyan@...il.com>
To: David Laight <David.Laight@...lab.com>
Cc: "akpm@...ux-foundation.org" <akpm@...ux-foundation.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] Drop -Wdeclaration-after-statement
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.
Powered by blists - more mailing lists