int hashOf( const(void)[] buf )
{
auto data = cast(const(ubyte)*) buf.ptr;
return 3;
}
enum hashval = hashOf("Sample_string");
-------------------------
bug.d(4): Error: pointer cast from const(void)* to const(ubyte)* is not supported at compile time
bug.d(8): called from here: hashOf("Sample_string")
Comment #1 by uplink.coder — 2016-06-26T23:11:23Z
The only way around this is passing ubyte[] instead of void[]
I actually like the rigorous type-safety at CTFE.
It's not a bug, It's a feature!
Comment #2 by ag.dlang — 2016-07-10T20:15:25Z
I know what a "void *" is for, but what is the intent of a "const(void)[]"? Does it have a valid length? Does it behave any differently than a "void[]"?
Comment #3 by ag0aep6g — 2016-07-10T20:27:44Z
(In reply to Andrew Godfrey from comment #2)
> I know what a "void *" is for, but what is the intent of a "const(void)[]"?
> Does it have a valid length? Does it behave any differently than a "void[]"?
Please ask such questions in the Learn group of the forum:
http://forum.dlang.org/group/learn
Regarding void[], see http://dlang.org/spec/arrays.html (section "Void Arrays" near the bottom). If that doesn't answer all your questions, please make a thread in the forum.
Comment #4 by ag.dlang — 2016-07-10T21:04:55Z
(In reply to ag0aep6g from comment #3)
> (In reply to Andrew Godfrey from comment #2)
> > I know what a "void *" is for, but what is the intent of a "const(void)[]"?
> > Does it have a valid length? Does it behave any differently than a "void[]"?
>
> Please ask such questions in the Learn group of the forum:
> http://forum.dlang.org/group/learn
>
> Regarding void[], see http://dlang.org/spec/arrays.html (section "Void
> Arrays" near the bottom). If that doesn't answer all your questions, please
> make a thread in the forum.
Thanks for the link. I've read that before but didn't retain it.
To this bug, I'm still wondering if it's specific to the const case.
Comment #5 by robert.schadek — 2024-12-13T18:48:40Z