Immutable cannot be casted to const when using pointers
Jeroen Bollen
jbinero at gmail.com
Tue Apr 8 14:05:09 PDT 2014
For some reason this code doesn't work...
module app;
void main() {
immutable char var = 'a';
immutable(char)* varPtr = &var;
test(&varPtr);
}
void test(immutable(char)** param) {
test2(param);
}
void test2(const(char)** test2) {
}
It'll give you " Error: function app.test2 (const(char)** test2)
is not callable using argument types (immutable(char)**)", which
makes no sense as if a function requests a constant variable,
immutable should suffice.
What's even weirder (although it is what should happen), if you
remove one of the pointers, it compiles fine.
module app;
void main() {
immutable char var = 'a';
test(&var);
}
void test(immutable(char)* param) {
test2(param);
}
void test2(const(char)* test2) {
}
Is this a bug? I'm using DMD.
More information about the Digitalmars-d
mailing list