Errors, bugs, questions - page 1576

 

I wonder what principle is used to put products in this banner

and do products from authorised sellers go there? I mean, can I see my product in this banner? I've flipped through 30 pages and haven't seen mine...

 
Renat Fatkhullin:

I do not interfere. I have 26 years of non-stop programming under my belt.

Warnings are essentially errors if we are talking about the financial sector. And all the thousands of reports of "loss of sign, loss of accuracy, loss on ghosts, etc." are verdicts on code quality. Apparently you don't quite understand the implications.

Please provide in a sufficiently full form the piece of code the compiler has pointed out as an error.

Without it all this discussion looks unsightly and unfair.

Ok, Renat, these arguments about "code quality" are irrelevant to the topic of discussion. For we are only talking about compilability here, i.e. the workability of the code. And the loss of accuracy, etc. - this is a personal matter of the programmer, so to say his/her responsibility. Implicit conversion e.g. int to short is not forbidden by the language standard, right? So why are we preaching now?

OK, I've found one of these bugs:

class CClass
{

};


class CArr
{
  CClass* data[];
 public: 
  CClass* operator[] (int i)  { return data[i]; }
};


template<typename T>
void Func (T* obj)      {  }
 

void OnStart()
{  
  CArr arr;
  Func(arr[0]);
}

which I get in the log:

'CClass' - declaration without type TestScript.mq5 16 9
'CClass' - comma expected TestScript.mq5 16 9

In previous builds everything was fine.

 
Alexey Navoykov:

OK, Renat, these arguments about "code quality" are irrelevant to the topic of discussion. For we are only talking about compilability, i.e. the workability of the code here. And the loss of accuracy, etc. - this is a personal matter of the programmer, so to say his/her responsibility. Implicit conversion e.g. int to short is not forbidden by the language standard, right? So why are we preaching now?

2600 potentially problematic places, and even in finances - this is not a moral, but exactly the indicator of code quality.


OK, I've found one of these bugs:

which I get in the log:

In previous builds everything was fine.

Yes, this bug was already discussed (probably, with A100) and fixed on May 4. Overdid it with type control, apparently.

I attached the latest MetaEditor build 1329, which does not have this error. Please check it there.

The release of MT5 will be on May 12.

Files:
 
Alexey Navoykov:

It was fine in previous builds.

In your code, you are not returning a const-pointer to a private object. It turns out that third-party (in terms of variable visibility) functions can change seemingly something that should not be architecturally accessible to them, since the programmer has specified private.

Whenever I want to return a pointer to a private object, I necessarily specify a const modifier. In your case I would set a warping.

I am not a high flyer so I am asking. Do you have to use this code somewhere or is it just lazy to set const?

 
A100:

Two days wasted practically the whole time (at my age it's already a lot), and I had planned to use them in a slightly different way.

You cited more than a hundred bugs. Each time such a wild amount of your time?! Where did you get such generosity towards the developers?
Alexey Navoykov:

So, once again, I take my hat off to A100 for his patience. I'm tired of it myself, it's easier for me to sit on the old build, which works fine, than to search for causes of bugs in the new build, working on service-desk. Or someone will pay me for this work?

Yes, servicedesk is a cool thing for third party testers to do for free. Obviously it wasn't made for that, but in fact it has become exactly the employer for third party testers working for free. If it wasn't for these bug reports, the compiler would have taken much longer to compile.

Everyone will argue that there should be retribution for finding a bug, as is the practice in the world. A100 should get the state tester's salary. And seemingly a year's worth of tester's salary.

 
Renat Fatkhullin:

Yes, this error has already been discussed (perhaps with A100) and fixed as early as May 4. They have overdone type control, apparently.

I attached the latest MetaEditor build 1329 that does not contain this error. Please check it there.

The MT5 release will be on May 12.

Checked. There are almost no compilation errors now, except for some strange wonders which I cannot reproduce separately from the program, but manage to bypass in some random way.

Below is an sample code of the problem area I'm going to tell you about. Again, it compiles well separately but generates an error in my program.

class CBase
{
};


class CClass : public CBase
{
};

 

class CWork
{
 public:
 
  template<typename T>
  void Run(T& arr[])
  {
    struct Struct
    {
      template<typename T1> static void Set(T1& main,  T& arr[], CBase& obj)   { main.Set(arr); } 
    };
    
    Struct structobj;
    
    structobj.Set(this, arr, arr[0]);
  }

  
  template<typename T>
  void Set(T& arr[]) 
  {  
    for (int i=0; i<ArraySize(arr); i++) Set(arr[i]);  // Здесь возникает ошибка: 'arr' - parameter conversion not allowed
  }
  
  template<typename T>
  void Set(T& obj)    { } 
  
  template<typename T>
  void Set(T*& obj)    { } 

};
 
 

void Main()
{
  CWork work;
  CClass arr[];
  work.Run(arr);

  return;
}

If you add a line in the Main function in any place (for example, after return):

work.Set(arr[0]);

it compiles normally.

The programmer seems to have gone too far in optimization.

And also there are some glitches in the runtime. For example, I assign a value to some member of a structure but later it turns out that the value there is old, i.e. nothing was assigned. If I add a line with some arbitrary operation near it, everything becomes normal. These bugs have started since that autumn build when you optimized the compiler. All in all, everything is still raw.

Besides, the compilation itself still takes 20 seconds, while the build 1159 only took 1-2 seconds. At the same time I don't notice any significant speed-up of my programs, the gain is within 10-20%. So you can forget those stories about 2-10x speedup. May be it happens with specially selected test samples, but we have real applications, not fake ones.

Altogether 10-20-fold slower compilation for the sake of a bit higher performance. Imho, it's not worth it. The programmer's time lost is much more valuable.

I'm still forced to stay on 1159 build.

 
Anton Zverev:

In your code, you are not returning a const-pointer to a private object. It turns out that third-party (in terms of variable visibility) functions can change seemingly something that should not be architecturally accessible to them, since the programmer has specified private.

Whenever I want to return a pointer to a private object, I necessarily specify a const modifier. In your case I would put a warping on it.

I am not a high flyer so I am asking. Do you have to use this code somewhere or is it just lazy to set const?

I only hide an array in private while the CClass objects themselves are available to a user for full access, that's the purpose. If I needed it only for reading, I would put const.

 
Anton Zverev:
All will support that there should be retribution for finding a bug, as is the practice in the world. A100 should get a state tester's salary. And seemingly a year's worth of tester's salary.
I support that, but I'm afraid it will be limited to a plaque and a letter of commendation :)
 

I don't know if this is a bug or just a wrong description of the CDealInfoPositionId() andTicket() methods. I wrote the following code

//+------------------------------------------------------------------+
//|                                                      test_01.mq5 |
//|                                                   Sergey Gritsay |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Sergey Gritsay"
#property link      "https://www.mql5.com"
#property version   "1.00"
#include <Trade\Trade.mqh>
//#include <Trade\DealInfo.mqh>
CTrade trade;
CDealInfo deal;
ulong  ticket_deal;      // тикет сделки
ulong  ticket_position;     // тикет позиции
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   trade.Buy(0.1,_Symbol);
   ticket_deal=trade.ResultDeal();
   deal.Ticket(ticket_deal);
   ticket_position=deal.PositionId();

   Print("ResultDeal() = ",ticket_deal);
   Print("deal.PositionId() = ",ticket_position);
  }
//+------------------------------------------------------------------+

result

NM      0       14:06:49.083    test_01 (EURUSD,H1)     ResultDeal() = 69380150
QE      0       14:06:49.083    test_01 (EURUSD,H1)     deal.PositionId() = 0

I added a request for the history of deals using theHistorySelect() function.

//+------------------------------------------------------------------+
//|                                                      test_01.mq5 |
//|                                                   Sergey Gritsay |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Sergey Gritsay"
#property link      "https://www.mql5.com"
#property version   "1.00"
#include <Trade\Trade.mqh>
//#include <Trade\DealInfo.mqh>
CTrade trade;
CDealInfo deal;
ulong  ticket_deal;      // тикет сделки
ulong  ticket_position;     // тикет позиции
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   trade.Buy(0.1,_Symbol);
   ticket_deal=trade.ResultDeal();
   HistorySelect(0,TimeCurrent());
   deal.Ticket(ticket_deal);
   ticket_position=deal.PositionId();

   Print("ResultDeal() = ",ticket_deal);
   Print("deal.PositionId() = ",ticket_position);
  }
//+------------------------------------------------------------------+

result

JM      0       14:16:33.055    test_01 (EURUSD,H1)     ResultDeal() = 69381116
EF      0       14:16:33.055    test_01 (EURUSD,H1)     deal.PositionId() = 83654708
 
Alexey Navoykov:

I only hide the array in private, and the CClass objects themselves are available to the user for full access, that's the purpose. If I needed it to be read only, I would put const.

I see. Can you tell me in which constructs this may be useful? I understand that with this approach, you can't do anything with the array itself (resize, swap elements, etc.). delete, however, can be applied...

I assume you do it somewhere with a template, so that the syntax of the [] operator is the same for different object types. In general, could you show the use of this construct when it's convenient.

Reason: