So, it builds fine with gcc-4.1.1, but if you compile with -O or
greater, some operations are broken, such as add and multiply.
Looking at the source, the broken operations all use PopArg() twice
in the same line. PopArg() is actually replaced by
argStack[--argStackP] as a define.
ac = PopArg() + PopArg();
ac = argStack[--argStackP] + argStack[--argStackP];
Which has undefined behaviour according to the gcc folks:
Basically, the --argStackP are done in a random order at best, which results in broken results from the calculator.
I've attached a patch that fixes this broken code. Thanks to lu_zero for confirming it. :)
Created attachment 92170 [details, diff]
Fixes the above issue.
I've committed this since it's a simple fix and the only ebuild in portage was broken. Hope you don't mind! It should eventually go stable, but I'll leave that up to the sci herd.