Skip to content

3C loses struct definition as part of a field nested in another struct definition #531

Closed
@mattmccutchen-cci

Description

@mattmccutchen-cci

Example reduced from libarchive:

struct outer {
  struct inner {
    int x;
  } i_arr[1];
};

int foo(struct outer *o) {
  return o->i_arr[0].x;
}

3c -alltypes produces:

struct outer {
  struct inner i_arr _Checked[1];
};

int foo(_Ptr<struct outer> o) {
  return o->i_arr[0].x;
}

We lost the definition of struct inner, so we get the following compile error:

nested-struct.checked.c:2:30: error: array has incomplete element type 'struct inner'
  struct inner i_arr _Checked[1];
                             ^

I believe this also explains at least some of the "incomplete definition of type" errors in libarchive, though I haven't confirmed that. I haven't looked into whether there are other variants of the example that trigger the bug without using an array.

It looks like 3C has code somewhere that splits struct inner { ... } i_arr[1]; into struct inner { ... }; and struct inner i_arr[1]; when it occurs at the top level, but this doesn't work for nested structs.

Metadata

Metadata

Labels

benchmark failureA bug causing a failure in our nightly benchmark testsbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions