Thread overview | ||||||
---|---|---|---|---|---|---|
|
September 20, 2014 Are void arrays usable ? | ||||
---|---|---|---|---|
| ||||
Hello, I just discovered this strange behavior: struct A { void[10] x; // OK, compiles fine } class B { void[10] x; // Error: void does not have a default initializer // ! note, the message come without any line indication ! } Does this mean that void arrays are a thing or it is a bug ? |
September 20, 2014 Re: Are void arrays usable ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to badlink | badlink:
> Does this mean that void arrays are a thing or it is a bug ?
You can compile that with:
class Foo {
void[10] x = void;
}
But this code shows a dmd bug (lack of line number):
class Foo {
void[10] x;
}
void main() {}
Error: void does not have a default initializer
Take a look in bugzilla, if it's not already present file it.
Bye,
bearophile
|
September 20, 2014 Re: Are void arrays usable ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | > Take a look in bugzilla, if it's not already present file it. https://issues.dlang.org/show_bug.cgi?id=13505 Bye, bearophile |
September 20, 2014 Re: Are void arrays usable ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to badlink | On Sat, Sep 20, 2014 at 10:09:25AM +0000, badlink via Digitalmars-d-learn wrote: > Hello, > I just discovered this strange behavior: > > struct A { > void[10] x; // OK, compiles fine > } > class B { > void[10] x; // Error: void does not have a default initializer > // ! note, the message come without any line indication ! > } > > Does this mean that void arrays are a thing or it is a bug ? void[] is a wildcard array type that represents a block of memory that contains an array of some sort. It behaves like ubyte[], except that it may be GC-scanned for pointers (ubyte[] AFAIK is not scanned because you're not expected to store pointers in it, but void[] represents *any* array and thus may contain pointers). T -- Not all rumours are as misleading as this one. |
Copyright © 1999-2021 by the D Language Foundation