Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
March 30, 2017 [Issue 17287] [ICE] backend/cgcod.c 255: zero length static arrays | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=17287 Илья Ярошенко <ilyayaroshenko@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |ice-on-valid-code -- |
March 30, 2017 [Issue 17287] [ICE] backend/cgcod.c 255: zero length static arrays | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=17287 Stefan Koch <uplink.coder@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|ice-on-valid-code |accepts-invalid CC| |uplink.coder@gmail.com Severity|major |normal --- Comment #1 from Stefan Koch <uplink.coder@gmail.com> --- Apparently no one has written such code. until now, otherwise this issue would have surfaced sooner. any length zero array is non-nonsensical in D. -- |
March 30, 2017 [Issue 17287] [ICE] backend/cgcod.c 255: zero length static arrays | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=17287 ZombineDev <petar.p.kirov@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|accepts-invalid |ice-on-valid-code CC| |petar.p.kirov@gmail.com Hardware|x86 |All --- Comment #2 from ZombineDev <petar.p.kirov@gmail.com> --- @Stefan It easily comes up in generic code when length is based on some calculation and/or code generation via string mixins For reference see http://docs.algorithm.dlang.io/latest/mir_ndslice_slice.html#Slice and browse through the source code (https://github.com/libmir/mir-algorithm). T[0] is pretty normal if you think about it as struct S { }. If passing around structs without any members works, why wouldn't zero-sized static arrays be ok? Structs without members are invalid in C, but on the contrary are quite common in C++ and similarly D allows them for a reason. See also http://en.cppreference.com/w/cpp/language/ebo, https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html and http://dlang.org/spec/arrays.html: > A static array with a dimension of 0 is allowed, but no space is allocated for it. It's useful as the last member of a variable length struct, or as the degenerate case of a template expansion. -- |
March 30, 2017 [Issue 17287] [ICE] backend/cgcod.c 255: zero length static arrays | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=17287 hsteoh@quickfur.ath.cx changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |hsteoh@quickfur.ath.cx --- Comment #3 from hsteoh@quickfur.ath.cx --- I've used zero-length static arrays at the end of structs before, and they work, for the most part. I'm surprised having a zero-length member in the middle of a struct causes an ICE, though. Or is it the zero-length ctor parameter that's causing the problem? -- |
March 30, 2017 [Issue 17287] [ICE] backend/cgcod.c 255: zero length static arrays | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=17287 --- Comment #4 from Илья Ярошенко <ilyayaroshenko@gmail.com> --- (In reply to hsteoh from comment #3) > I've used zero-length static arrays at the end of structs before, and they work, for the most part. I'm surprised having a zero-length member in the middle of a struct causes an ICE, though. Or is it the zero-length ctor parameter that's causing the problem? It is all factors together. No one line can be removed to reduce this example. -- |
March 30, 2017 [Issue 17287] [ICE] backend/cgcod.c 255: zero length static arrays | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=17287 --- Comment #5 from kinke@gmx.net --- (In reply to Илья Ярошенко from comment #4) > (In reply to hsteoh from comment #3) > > I've used zero-length static arrays at the end of structs before, and they work, for the most part. I'm surprised having a zero-length member in the middle of a struct causes an ICE, though. Or is it the zero-length ctor parameter that's causing the problem? > > It is all factors together. No one line can be removed to reduce this example. We've had the same issue with LDC. Zero-length static arrays are so special because they are the only type with a size of 0. Empty structs have a size of 1. If I recall correctly, we ended up ignoring zero-sized aggregate fields in the backend and passing/returning them as byte (analogous to empty structs). -- |
April 12, 2019 [Issue 17287] [ICE] backend/cgcod.c 255: zero length static arrays | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=17287 Илья Ярошенко <ilyayaroshenko@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |FIXED -- |
Copyright © 1999-2021 by the D Language Foundation