Hotfix arithmetic bug
There is a bug in util_arithmetic_expr
that compares a pointer to a string.
This bug results in the function left_associative
not working as expected.
And therefore produces wrong expression results for complicated expressions with ^
operators.
The test TEST_exr_3 + 4*2/(1 - 5)^2^3
is a very good example.
When we use left-associative (default for C) for the power operator, the expression x^2^3
should be (x^2)^3=x^6
.
When we use right-associative (default for Fortran) for the power operator, the expression x^2^3
should be x^(2^3)=x^8
.
This branch fixes this bug.
Additionally, this branch also fixed the problem that the Ragel state machine no longer compiles the *.rl
files.
This branch also updates FortUTF to the latest version.
Merge request reports
Activity
added bug label
requested review from @b381001
assigned to @b382190
Thank you very much for the fix. Our unittest seem already to payoff and reveal potential bugs :-)
I would like to add @m300196 as a reviewer here, since he is the original author of this code.
I am not that familiar with which (left or right) we should use. But in the original code,
^
was set to be right-associative. https://gitlab.dkrz.de/icon-libraries/libfortran-support/-/blob/hotfix_arithmetic_bug/src/util_arithmetic_expr.c#L17
Maybe because this code is only used by calling from a Fortran module?
added 1 commit
- fbd42b97 - Add the power operator to the left-associative list
added 1 commit
- 8e51431e - Update the comment, adding the Ragel compiler version
mentioned in commit 8137bc69