https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107951

            Bug ID: 107951
           Summary: Invalid flexible array use not detected in nested
                    structs by the C frontend
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: siddhesh at gcc dot gnu.org
  Target Milestone: ---

The following program:

typedef struct {
  char pad;
  char data[];
} F2;

typedef struct {
  F2 flex;
  unsigned pad;
} S2;

#define NULL (void *) 0

__SIZE_TYPE__
nested_flexarray (__SIZE_TYPE__ n)
{
  S2 *p = __builtin_malloc (n);

  return __builtin_dynamic_object_size (p->flex.data, 1);
}

ends up treating data[] as a zero sized array in C instead of flagging an
error.  This is correctly handled in the C++ driver.

Reply via email to