Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

P0332 implies array incompleteness is no longer "local" #34

Open
dhollman opened this issue Nov 14, 2017 · 2 comments
Open

P0332 implies array incompleteness is no longer "local" #34

dhollman opened this issue Nov 14, 2017 · 2 comments

Comments

@dhollman
Copy link
Contributor

After working on a patch to clang for P0332 (pull request with patch coming soon), the biggest issue I see with this proposal is that array incompleteness is no longer "local" (I don't have a better word for this, but it will become clear what I mean pretty soon). That is, you only have to look at the outermost extent to determine the completeness of an array type. Because of this, we can always say that an array type is:

  • complete, T[N], and we don't care about the extents of T (if any) as long as T is a complete type. Thus we only have to store information about [N] with the type and we can treat everything else recursively.
  • incomplete, T[], and we don't care about the extents of T (if any) as long as T is a complete type.

Note that in both cases, we only have to examine one "layer" of the completeness of T, and zero layers of the extents.

Now consider the state of affairs under P0332. Given a type T[N],

  • the type is complete if T is not an array type.
  • if T is an array type of the form U[M], we have to (recursively) examine the completeness of U.
  • if T is an array of the form U[], we know that T[N] is an incomplete type, but we still have to expand the definition of incomplete type to include N (in addition to the extents, if any, of U)

This would lead to some structural changes in the way array types are described in clang. It's not a deal-breaker by any means, but it's emblematic of why this is not a trivial change.

@hcedwar
Copy link
Contributor

hcedwar commented Nov 16, 2017

We need a taxonomy of incomplete types. The standard talks about incomplete types in many ways: cv void, incomplete class, array of unknown bound, incomplete type that cannot be completed, incompletely-defined object type, array of incomplete class type, incomplete non-void type, incomplete object type, incompletely defined class, etc.

@hcedwar
Copy link
Contributor

hcedwar commented Nov 16, 2017

The taxonomy rules may be well-defined and non-recursive.

An incomplete type is

  1. cv void

  2. incomplete class type : class X;

  3. array of incomplete class type : X[N]

  4. array of unknown bound : T[]

The T of an array of unknown bound may be a complete type, incomplete class type, array of incomplete class type, or an array of unknown bound.

An array type T[N] is

  1. a complete type if T is a complete type

  2. an array of incomplete class type if T is an incomplete class type or array of incomplete class type

  3. an array of unknown bound if T is an array of unknown bound

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants