Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.
This repository was archived by the owner on Mar 27, 2025. It is now read-only.

ambiguous corner cases in calling convention regarding zero-length arrays #48

Description

@xry111

Consider such cases:

Case 1:

struct f
{
	double x[0];   /* This is a GNU extension.  */
	double a;
	double b;
};

Case 2:

struct f
{
        float x[0];
        float b;
};

Case 3:

struct f
{
        double x[0];
        float b;
};

Current calling convention doc is not clear on "if f::x is considered a member", "if f::x is considered a floating-point member", and "if f::x is considered one float (or double) member". Note that we are saying:

Empty structures are ignored by C compilers which support them as a non-standard extension

But it does not cover "empty" arrays.

And current GCC trunk is doing strange things (IMO). For Case 2, it passes b in FAR. But for Case 3, it passes b in GAR.

In my opinion the most "clear" solution is to ignore the empty arrays (and bitfields: https://gcc.gnu.org/PR102024) altogether with empty aggreates. But that will requires to update GCC behavior, fortunately we still have an oppertunity to do this before GCC 12 release (if we move fast). CC GCC maintainers: @ChenghuaXu @chenglulu

Another solution is to document the current GCC behavior clearly in the doc. But I don't know to write it (as I consider the current behavior "strange").

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions