Errors, bugs, questions - page 1644

 
Alexey Navoykov:
Did you come to us from the distant past? )
No, a little closer.
 
A100:

Compile error: ')' - not all control paths return a value

Well, frankly speaking, this is an absurd example. Even if C++ allows it, but is this case possible in a real application? Why should we put a loop there if there is only one iteration?
 
Alexey Navoykov:
Well, frankly speaking, this is an absurd example. Even if C++ allows it, but is this case possible in a real application? Why would you put a loop there if there is only one iteration?

Why one, if in the sense it is an endless cycle and it is written to continue

And sometimes you need one, can you guess when? I'll give you a hint - to get out of a complicated if-else-switch like goto without unnecessary flags and other excesses

 
A100:

Why one, if it is an endless cycle and continues

And there are times when you need one, can you guess when?

Oh, I just didn't notice that you've got something written in the comments there... It was hard to show it in the code, was it?
 

In general, it's not very clear what exactly is meant by "under many lines with return, continue, without break". is there an if?

p.s. Got it.

 
Sergei Vladimirov:
In his example, all of them. An exit from while(true) is possible only through break operator (which it doesn't have) or return.
Vitalii Ananev:
I'm not going to argue. But the compiler error message ')' - not all control paths return a value, it says the opposite.

What is the inverse of that? That it's not only possible to exit with a break or return? ))

 
Alexey Navoykov:
In general, it's not very clear what exactly is meant by "under many lines c return, continue, no break". is there an if?

It doesn't matter. Playable even with an empty cycle:

bool Func()
{
   while(true)
   {
      return true;
   }
}
//')' - not all control paths return a value	Temp Script.mq4	25	1


 
Sergei Vladimirov:

About the opposite of what? That it's not only possible to exit with a break or return? ))

That's what it's about.

Not all code branches return a value. .....

I mean that not all the branches in the code above return a value. It is in such cases that the compiler generates this error.

 
Vitalii Ananev:

This is about that.

That not all branches of the above code return a value. It is in such cases that the compiler generates this error.

That's what I'm saying: the error message is wrong.
 
Sergei Vladimirov:

It doesn't matter. Playable even with an empty cycle:

That's what I'm saying, the error message is wrong.

He didn't give the full code, and apparently that full code has branching operators.

Reason: