Re: Add compiler option -fstrict-flex-arrays=1

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: David Geier <geidav(dot)pg(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: Tristan Partin <tristan(at)partin(dot)io>, Greg Burd <greg(at)burd(dot)me>
Subject: Re: Add compiler option -fstrict-flex-arrays=1
Date: 2026-10-23 22:15:07
Message-ID: 4b376dd4-4d95-4982-9362-d38d39c2a56f@eisentraut.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 20.10.26 14:37, David Geier wrote:
>>>> If we turned on -fstrict-flex-arrays=3, these would become undefined
>>>> behavior and trigger the ubsan sanitizer.
>>>
>>> The compiler setting can be changed on a per-struct basis via
>>>
>>> __attribute__((strict_flex_arrays(N)));
>>
>> This only works with gcc, not clang, so it's not a viable solution.
>
> clang has support for it starting with version 16.0, see [1]. Is that
> clang version too recent to require it?
>
> --
> David Geier
>
> [1] https://releases.llvm.org/16.0.0/tools/clang/docs/ReleaseNotes.html

I don't see the attribute mentioned in the release notes. The only
thing related that I see in there is that that release now supports the
level 3 of -fstrict-flex-arrays where the previous versions only
supported up to 2. My testing confirms that no version of clang
supports the attribute.

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message surya poondla 2026-10-23 21:50:18 Re: Parallel vacuum: workers together with leader could overrun cost budget