diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE index 6edc63a2014..7456d604a91 100644 --- a/gcc/d/dmd/MERGE +++ b/gcc/d/dmd/MERGE @@ -1,4 +1,4 @@ -c74e624c9a0a9e7e39f96b2f005f86e123df56c9 +420cce2a654f14b8de4a75cbb5d4203fce8d4e0f The first line of this file holds the git revision number of the last merge done from the dlang/dmd repository. diff --git a/gcc/d/dmd/dinterpret.c b/gcc/d/dmd/dinterpret.c index acca4e8097d..0749c7f487d 100644 --- a/gcc/d/dmd/dinterpret.c +++ b/gcc/d/dmd/dinterpret.c @@ -6053,9 +6053,16 @@ public: result = (*se->elements)[i]; if (!result) { - e->error("Internal Compiler Error: null field %s", v->toChars()); - result = CTFEExp::cantexp; - return; + // https://issues.dlang.org/show_bug.cgi?id=19897 + // Zero-length fields don't have an initializer. + if (v->type->size() == 0) + result = voidInitLiteral(e->type, v).copy(); + else + { + e->error("Internal Compiler Error: null field %s", v->toChars()); + result = CTFEExp::cantexp; + return; + } } if (result->op == TOKvoid) { diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail19897.d b/gcc/testsuite/gdc.test/fail_compilation/fail19897.d new file mode 100644 index 00000000000..8dd4e149a87 --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/fail19897.d @@ -0,0 +1,13 @@ +// PERMUTE_ARGS: +/* +TEST_OUTPUT +--- +fail_compilation/fail19897.d(10): Error: cannot implicitly convert expression `[]` of type `const(char[0])` to `const(char)` +--- +*/ +struct S +{ + char[0] x; +} +const a = S('a'); +const char c = a.x;