Struct initialization with compatible type

From: Xavier Del Campo Romero <xavi92_at_disroot.org>
Date: Thu, 24 Apr 2025 23:49:01 +0200

Hi,

scc (commit d0ec99aa) fails to compile the following minimalistic example:

$ cat struct.c
struct a {
    int a;
};

int main()
{
    struct a a;
    struct a aa = a;

    return 0;
}
$ scc struct.c
struct.c:8: error: incorrect initializer

However, this is valid syntax, according to C99 6.7.8p13:

> The initializer for a structure or union object that has automatic
> storage duration shall be either an initializer list as described

> below, or a single expression that has compatible structure or union
> type. In the latter case, the initial value of the object, including
> unnamed members, is that of the expression.

Best regards,

--
Xavier Del Campo Romero





--
To unsubscribe send a mail to scc-dev+unsubscribe_at_simple-cc.org
Received on Thu 24 Apr 2025 - 23:49:01 CEST

This archive was generated by hypermail 2.3.0 : Thu 24 Apr 2025 - 23:50:02 CEST