diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2021-07-26 15:11:42 +0200 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gdcproject.org> | 2021-07-28 13:13:05 +0200 |
commit | c936c39f86c74b3bfc6831f694b3165296c99dc0 (patch) | |
tree | 1ec07b3f72bc318fa0a2e16dbdac4b544c659154 /gcc/testsuite/gdc.dg | |
parent | 1a2306ffe79df89389cc850ce85c586d0f1c8264 (diff) | |
download | gcc-c936c39f86c74b3bfc6831f694b3165296c99dc0.zip gcc-c936c39f86c74b3bfc6831f694b3165296c99dc0.tar.gz gcc-c936c39f86c74b3bfc6831f694b3165296c99dc0.tar.bz2 |
d: fix ICE at convert_expr(tree_node*, Type*, Type*) (PR101490)
Both the front-end and code generator had a modulo by zero bug when testing if
a conversion from a static array to dynamic array was valid.
PR d/101490
gcc/d/ChangeLog:
* dmd/MERGE: Merge upstream dmd 27e388b4c.
* d-codegen.cc (build_array_index): Handle void arrays same as byte.
* d-convert.cc (convert_expr): Handle converting to zero-sized arrays.
gcc/testsuite/ChangeLog:
* gdc.dg/pr101490.d: New test.
Diffstat (limited to 'gcc/testsuite/gdc.dg')
-rw-r--r-- | gcc/testsuite/gdc.dg/pr101490.d | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/gcc/testsuite/gdc.dg/pr101490.d b/gcc/testsuite/gdc.dg/pr101490.d new file mode 100644 index 0000000..6929d40 --- /dev/null +++ b/gcc/testsuite/gdc.dg/pr101490.d @@ -0,0 +1,21 @@ +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101490 +// { dg-do compile } + +struct S101490 +{ + int[0] arr; +} + +void main() +{ + S101490* t; + auto a = cast(typeof(t.arr)[0])t.arr; + write(a); +} + +void write(S)(S args) +{ + foreach (arg; args) + { + } +} |