FIXED: call non-const method for constant object error after updating to build 3440
Is this a bug of the new build?
There was no way to "discriminate between the two". It should have been caught and not compiled previously.
It is a bug, as it could not have compiled.
There was no way to "discriminate between the two". It should have been caught and not compiled previously.
It is a bug, as it could not have compiled.
Actually, there IS a way to discriminate between the two: the compiler chooses the const overload when the function is called on a const object (or via a reference or pointer to const), it chooses the other overload otherwise.
So the compiler uses the const version of the CA::GetPtr() function with the CB::Get() and the non const version with the CB::Set().
I have found a problem in some code that compiled correctly before updating to build 3440.
I have simplified the problem to these few lines of code:
The error I get is the following:
This code compiles perfectly on an older release, for example with build 3325, and, launching this script on a EURUSD chart, I obtain:
demonstrating that it calls the right version (const / non const) of the GetPtr() function.
This problem can be solved by renaming one of the two GetPtr() functions and explicitly calling the const or the non const version, showing that the compiler is no longer able to automatically discriminate between the two.
Is this a bug of the new build?
Thank you for your help.