# The boiler function without return'a returns the correct value

• Working in QT 6.2 I've got a program that counts the area of an arbitrary, simple multiangle. Before the counting, I'm checking a multiangle at the crossroads.

``````if(!cross(polygon, n))
{
double S = square(polygon,n);
if(!(qIsInf(S)))
{
ui->l_Sq->setText("Площадь: " + QString::number(S));
}
else
{
warning("Многоугольник слишком большой(");
}
}
else
{
warning("Я умею работать только с простыми многоугольниками(");
}
``````

That's why I'm calling a buoy line. `not_cross()`

``````bool cross(double **polygon, int n = 0) // Ф-ция  проверки на пересечение сторон многоугольника
{
bool not_cross = true;
double x1,x2,x3,x4;
double y1,y2,y3,y4;
double v1,v2,v3,v4;
for (int i=0; i&lt;n&amp;&amp;not_cross; i++)
{
int k = (i+1)%n;
x1 = polygon[i][0]; x2 = polygon[k][0];
y1 = polygon[i][1]; y2 = polygon[k][1];
for (int j = 0; j&lt;n&amp;&amp;not_cross; j++)
{
int m = (i+j)%n;
int v = (m+1)%n;
if(abs(i-m) &lt;= 1)
continue;
x3 = polygon[m][0]; x4 = polygon[v][0];
y3 = polygon[m][1]; y4 = polygon[v][1];

v1 = (x4-x3)*(y1-y3)-(y4-y3)*(x1-x3);
v2 = (x4-x3)*(y2-y3)-(y4-y3)*(x2-x3);
v3 = (x2-x1)*(y3-y1)-(y2-y1)*(x3-x1);
v4 = (x2-x1)*(y4-y1)-(y2-y1)*(x4-x1);

not_cross = !((v1*v2&lt;0) &amp;&amp; (v3*v4&lt;0)) &amp;&amp; not_cross;

}
}

}
``````

As you can see, this sentence does not exist. `return`♪ However, it still returns correct values. I mean, if the figure crosses, she'll come back. `true`if not intersected, `false`I think I've tested the program enough to avoid coincidences.
What's that got to do with it? Does the compiler think it's worth it? `not_cross`? If you finish the return, you'll have to write. `return !not_cross`(Yeah, I've got the code. I'm sorry, I was in a hurry.

• Technically, function without return, which does not voidin other words, a function that reaches the last brackets without meeting on its way `return (что-то)`It does. Undetermined behaviour

Undetermined conduct You may be the one you're expecting, but the program is incorrect.

2

2

2

2

2

2

2

2

2

2

2

2

2

2

2