DDF28a a = b - (c * d)
David Pitt (3386) 1248 posts |
There may be a further issue with DDE28a, cc 5.75. A recent compiler change is to do with handling integer expressions of the form :- a = b - (c * d) The following does not perform as expected when compiled with cc 5.75. #include <stdio.h> int main(void) { int a=0, b=10,c=4,d=2; printf("Hello DDE28a\n"); a = b - (c * d); printf("%d\n",a); if (a == 0) printf("Oh crap\n"); return(0); } The compilation is done with either !CC or Makefile, with either a DDE28a or Builder environments. It is OK with DDE27 and gcc. C and I don’t belong in the same sentence, so I thought I would ask. What does the team think? Edit, updated examples http://pittdj.co.uk/rool/test.zip |
Sprow (202) 1155 posts |
I don’t think that’s testing what you think its testing, since the values of b/c/d are known at compile time, the output code contains neither an MLS nor a MUL/SUB. If you force one of the variables to do some work to get it then the answer is right: int anumber(void) { return 4; } int main(void) { int a=0, b=10,c=anumber(),d=2; printf("Hello DDE28a\n"); a = b - (c * d); printf("%d\n",a); } That said, it should get it right so it’s worth reporting to ROOL, but in practice it’s unlikely to be a problem. You’ll note the change log includes a fix for compile time evaluation of modulo which hadn’t worked for years and nobody noticed (I found that one during some Econet testing). |
David Pitt (3386) 1248 posts |
The ReadMe in DDE28 has the forum as the point of contact for ROOL support. I have tidied up my example zip and removed inappropriate MLS references. For source and executables see http://pittdj.co.uk/rool/test.zip Further testing shows the issue is not present in the first issue of DDE28, cc 5.74. |
Rick Murray (539) 13806 posts |
Which change log?
That’s the ‘%’ operator isn’t it? I might have run into this building some #defines a few years ago. The results were not as expected. Rather than look into things, I just did the maths in BASIC and replaced the calculations with hardcoded values. It was something to do with seconds in day, hour, minute, etc… |