Re: Should we remove -Wdeclaration-after-statement?

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Andres Freund <andres(at)anarazel(dot)de>, Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Should we remove -Wdeclaration-after-statement?
Date: 2024-01-29 20:18:10
Message-ID: f3668fe5-9c89-d1ac-894b-d6130f0f1454@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 2024-01-29 Mo 14:58, Andres Freund wrote:
> Hi,
>
> On 2023-12-27 12:48:40 +0100, Jelte Fennema-Nio wrote:
>> Postgres currently requires all variables to be declared at the top of
>> the function, because it specifies -Wdeclaration-after-statement. One
>> of the reasons that we had this warning was because C89 required this
>> style of declaration. Requiring it everywhere made backporting easier,
>> since some of our older supported PG versions needed to compile on
>> C89. Now that we have dropped support for PG11 that reason goes away,
>> since now all supported Postgres versions require C99. So, I think
>> it's worth reconsidering if we want this warning to be enabled or not.
> +1 for allowing declarations to be intermixed with code,

I'm about +0.5.

Many Java, C++, Perl, and indeed C programmers might find it surprising
that we're having this debate. On the more modern language front the
same goes for Go and Rust. It seems clear that the language trend is
mostly in this direction.

But it's not something worth having a long and contentious debate over.
We have plenty of better candidates for that :-)

> -infinity for
> changing existing code to do so.

ditto. On that at least I think there's close to unanimous agreement.

cheers

andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2024-01-29 20:18:50 Re: cleanup patches for incremental backup
Previous Message Pavel Luzanov 2024-01-29 20:05:45 Re: Things I don't like about \du's "Attributes" column