[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202305111514.576EB7F@keescook>
Date: Thu, 11 May 2023 15:16:43 -0700
From: Kees Cook <keescook@...omium.org>
To: Joseph Myers <joseph@...esourcery.com>
Cc: Alejandro Colomar <alx.manpages@...il.com>, GCC <gcc@....gnu.org>,
Alejandro Colomar <alx@...nx.com>,
Andrew Clayton <a.clayton@...nx.com>,
Andrew Clayton <andrew@...ital-domain.net>,
linux-hardening@...r.kernel.org
Subject: Re: [wish] Flexible array members in unions
On Thu, May 11, 2023 at 09:43:49PM +0000, Joseph Myers wrote:
> On Thu, 11 May 2023, Kees Cook via Gcc wrote:
>
> > Why are zero-sized objects missing in Standard C? Or, perhaps, the better
> > question is: what's needed to support the idea of a zero-sized object?
>
> Zero-sized objects break the principle that different objects have
> different addresses, and the principle of being able to subtract pointers
> to different elements of an array. There would also be serious C++
> compatibility concerns, since C++ allows a struct with no members but it
> has nonzero size, unlike the GNU C extension where a struct with no
> members has size zero.
Okay, understood. If this is a C-only thing, we can ignore the C++
impact. What depends on the "different objects have different addresses"
principle? And why do unions not break this -- they could point to the
same locations within the object? And don't flexible arrays already need
special handling in this regard?
--
Kees Cook
Powered by blists - more mailing lists