Skip to content

Commit

Permalink
fix Issue 22411 - importC: Error: cannot implicitly convert expressio…
Browse files Browse the repository at this point in the history
…n of type 'const(char*)' to 'char*'
  • Loading branch information
ibuclaw committed Oct 19, 2021
1 parent 501d47b commit 0b71439
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/dmd/dcast.d
Original file line number Diff line number Diff line change
Expand Up @@ -1500,12 +1500,8 @@ MATCH cimplicitConvTo(Expression e, Type t)
return MATCH.convert;
if (tb.isintegral() && typeb.ty == Tpointer) // C11 6.3.2.3-6
return MATCH.convert;
if (tb.ty == Tpointer && typeb.ty == Tpointer)
{
if (tb.isTypePointer().next.ty == Tvoid ||
typeb.isTypePointer().next.ty == Tvoid)
return MATCH.convert; // convert to/from void* C11 6.3.2.3-1
}
if (tb.ty == Tpointer && typeb.ty == Tpointer) // C11 6.3.2.3-7
return MATCH.convert;

return implicitConvTo(e, t);
}
Expand Down
26 changes: 26 additions & 0 deletions test/compilable/testcstuff2.c
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,32 @@ typedef struct S22409
int f1;
} S22409_t;

/***************************************************/
// https://issues.dlang.org/show_bug.cgi?id=22411

extern char * const var22411[10];

void test22411()
{
char *cptr;
int *iptr;
float *fptr;
struct { int f1; int f2; } *sptr;
void (*fnptr)(void);

cptr = var22411[0];
iptr = var22411[1];
fptr = var22411[2];
sptr = var22411[3];
fnptr = var22411[4];

iptr = cptr;
fptr = sptr;
fnptr = iptr;
cptr = fptr;
sptr = fnptr;
}

/***************************************************/
// https://issues.dlang.org/show_bug.cgi?id=22413

Expand Down

0 comments on commit 0b71439

Please sign in to comment.