All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Joseph Myers <joseph@codesourcery.com>
Cc: Alejandro Colomar <alx.manpages@gmail.com>, GCC <gcc@gcc.gnu.org>,
	Alejandro Colomar <alx@nginx.com>,
	Andrew Clayton <a.clayton@nginx.com>,
	Andrew Clayton <andrew@digital-domain.net>,
	linux-hardening@vger.kernel.org
Subject: Re: [wish] Flexible array members in unions
Date: Thu, 11 May 2023 15:16:43 -0700	[thread overview]
Message-ID: <202305111514.576EB7F@keescook> (raw)
In-Reply-To: <bb3aac3c-f377-5598-cbf6-47d0be448f3@codesourcery.com>

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

  reply	other threads:[~2023-05-11 22:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <ac2550e0-2f5c-3680-08e6-0c224d043036@gmail.com>
     [not found] ` <44940599-7b43-99f6-5b09-4f050d645c7b@gmail.com>
2023-05-11 19:07   ` [wish] Flexible array members in unions Kees Cook
2023-05-11 20:53     ` Joseph Myers
2023-05-11 21:13       ` Kees Cook
2023-05-11 21:43         ` Joseph Myers
2023-05-11 22:16           ` Kees Cook [this message]
2023-05-11 22:52             ` Joseph Myers
2023-05-12  0:25               ` Alejandro Colomar
2023-05-12  6:16         ` Richard Biener
2023-05-15 19:58           ` Qing Zhao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202305111514.576EB7F@keescook \
    --to=keescook@chromium.org \
    --cc=a.clayton@nginx.com \
    --cc=alx.manpages@gmail.com \
    --cc=alx@nginx.com \
    --cc=andrew@digital-domain.net \
    --cc=gcc@gcc.gnu.org \
    --cc=joseph@codesourcery.com \
    --cc=linux-hardening@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.