Immutable cannot be casted to const when using pointers
Jeroen Bollen
jbinero at gmail.com
Tue Apr 8 14:08:19 PDT 2014
On Tuesday, 8 April 2014 at 21:07:29 UTC, John Colvin wrote:
> On Tuesday, 8 April 2014 at 21:05:10 UTC, Jeroen Bollen wrote:
>> 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.
>
> Looks like a bug to me.
Alright, filing it.
More information about the Digitalmars-d
mailing list