Re: [PATCH v3 1/2] uapi: fix __DECLARE_FLEX_ARRAY for C++

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


On Tue, Sep 12, 2023 at 07:22:24PM +0300, Alexey Dobriyan wrote:
> __DECLARE_FLEX_ARRAY(T, member) macro expands to
> 	struct {
> 		struct {} __empty_member;
> 		T member[];
> 	};
> which is subtly wrong in C++ because sizeof(struct{}) is 1 not 0,
> changing UAPI structures layouts.

Looking at this again just now, what about using a 0-length array
instead of an anonymous struct?

Then we don't need an #ifdef at all...

 	struct {
 		int __empty_member[0];
 		T member[];


Kees Cook

[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux