[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <59387c6677af43c18d434b4f3c1e5430@AcuMS.aculab.com>
Date: Fri, 25 Feb 2022 10:01:23 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Alexey Dobriyan' <adobriyan@...il.com>,
"akpm@...ux-foundation.org" <akpm@...ux-foundation.org>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH] Drop -Wdeclaration-after-statement
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.
But then it wouldn't be usable at global scope (is it anyway?)
> 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.
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.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists