Skip to content

Latest commit

 

History

History
40 lines (31 loc) · 1.41 KB

types.mkd

File metadata and controls

40 lines (31 loc) · 1.41 KB

Type Completion

When are types completed?

_Generic(0, struct S: 1, default: (struct S { int x; }) { 0 } );

Qualifiers

Qualifiers on function return types, parameters, and rvalues.

Compatibilty of Tagged Types

Two identically declared structs are not compatible (except when declared in different translation units).

struct foo { int x; } data;
void f(void)
{
   struct foo { int x; }* ptr = &data; // incompatible types
   ptr->x; // undefined behavior
}

Four identically declared structs may be incompatible and compatible at the same time. Consider the four structs:

// file 1
struct { int x; } s1;
struct { int x; } s2;
// file 2
struct { int x; } s3;
struct { int x; } s4;

s1 is compatible with s3 and s4 but not with s2. s2 iis compatible with s3 and s4 but not with s1. s3 is compatible with s1 and s2, but not s4. s4 is compatible with s1 and s2, but not with s3. Combine this with effective type fules (aliasing)...

Refs.: n1102, n2105, n2366, n2863

GCC patch