it’s almost certainly not a bug in MQL5, and not related to static .
You’re almost certainly hitting an invalid pointer / double-free in some destructor or hidden cleanup code that runs after your last line in TestReports()
You’re almost certainly hitting an invalid pointer / double-free in some destructor or hidden cleanup code that runs after your last line in TestReports()
void StatusReport::TestReports() { // ... int err = GetLastError(); // 0 here // return; }
int OnInit() { ResetLastError(); int err = GetLastError(); // 0 StatusReport::TestReports(); // call err = GetLastError(); // 4012 here }
Before the call → 0
Inside, just before return → 0
After the call → 4012
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
In my MQL5 EA, I have a class StatusReport that contains a method:
In OnInit() I have a call to
Before the call to TestReports(), the err = GetLastError(); returns 0.
At the end of TestReports(), before returning, the statement err = GetLastError(); returns 0;
Immediately following the return from TestReports(), the statement err = GetLastError(); returns 4012 (ERR_INVALID_POINTER). WHY?
If TestReports() had no _LastError just before the function return, why did OnInit() have a _LastError = 4012 immediately after the return from the call to:
Where did the _LastError pointer error (4012) come from following the return from the call to StatusReport::TestReports(); This call functions as it should.
Is there a better way to call a Method like TestReports(), defined within the class StatusReport ?
The MQL5 compiler required that the TestReports method with StatusReport to have a static access class declaration.
Is this error caused by a BUG in the MQL5 runtime system that should not otherwise happen?
What is the best way to eliminate this error?
Any Help is much appreciated.