ImportC: can't access members in static array (#21185)

Fixes https://github.com/dlang/dmd/issues/20472

Arrays in C implicitly convert to a pointer to their first member,
so do the implicit conversion when using them in an arrow member lookup.
This commit is contained in:
drpriver 2025-04-09 02:58:14 -07:00 committed by GitHub
parent 7dd0506aaf
commit ca2f90d1fc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 21 additions and 2 deletions

View file

@ -0,0 +1,12 @@
// https://github.com/dlang/dmd/issues/20472
typedef struct {
char c;
} stuff;
char test20472(void)
{
stuff s[1];
s->c = 1;
return s->c;
}
_Static_assert(test20472() == 1, "1");

View file

@ -398,8 +398,9 @@ void* tests3()
int tests4()
{
struct S { int b; } a, *p;
a.b = 3;
struct S { int b; } a, *p, b[1];
b->b = 3;
a.b = b->b;
p = &a;
return p->b;
}