This is not safe, because then you are relying on the order in which the expression is evaluated.
You have a point, hopefully compiler currently work left to right way regarding each sub-expression.
Anyway, your code will overflow as well when exceed int64 range.
Worst, for my own expression evaluator project I made clearing brackets after parsing if operation priority is the same, to speedup calculation (users 3D functions drawing), so in the future compiler releases may fail that as well...
As I wrote explanation, currently, in this case:
e:=8*n1*n1*m1*m2;
it is enough:
e:=double(1.0)*8*n1*n1*m1*m2;
If there is many sub-expressions (operation priority change), each will start regarding its own operand type and thus will lead to overflow.
I.e, this will overflow as well:
e:=double(1.0)*8*n1*n1*m1*m2+
8*n1*n1*m1*m2;
This will pass:
e:=double(1.0)*8*n1*n1*m1*m2+
double(1.0)*8*n1*n1*m1*m2;
After I looked at pictures provided by OP, I would suggest to change all function parameter types as well as in function variables to resulting one, regarding calculation complexity ...
I'm not sure there is a compiler directive about this (to get a resulting variable type for each subcalculation instead), but behavior with Delphi mode switch gives the same result as in FPC mode. This is definitely problematic, even if intention to speedup the calculation may have been the goal.