zertovitch / hac

HAC Ada Compiler - a small, quick Ada compiler fully in Ada
http://hacadacompiler.sf.net/
122 stars 11 forks source link

Too many digits (Mac M1) #13

Closed simonjwright closed 1 year ago

simonjwright commented 1 year ago
$ ./hac test/digitz.adb 
test/digitz.adb: 56:32-32: number is too large: total actual exponent is  16 > Max = 15
test/digitz.adb: 57:4-12: duplicate identifier: PUT_LINE
Errors found, build failed.

Two, maybe 3, problems here:

The reason that 16 digits is too many is that, on aarch64-apple-darwin (and maybe other aarch64 systems?), Long_Long_Float is the same as Long_Float; we have

   type Long_Float is digits 15
     range -16#0.FFFF_FFFF_FFFF_F8#E256 .. 16#0.FFFF_FFFF_FFFF_F8#E256;
   for Long_Float'Size use 64;

   type Long_Long_Float is digits 15
     range -16#0.FFFF_FFFF_FFFF_F8#E256 .. 16#0.FFFF_FFFF_FFFF_F8#E256;
   for Long_Long_Float'Size use 64;

vs on x86_64-apple-darwin we get

   type Long_Float is digits 15
     range -16#0.FFFF_FFFF_FFFF_F8#E256 .. 16#0.FFFF_FFFF_FFFF_F8#E256;
   for Long_Float'Size use 64;

   type Long_Long_Float is digits 18
     range -16#0.FFFF_FFFF_FFFF_FFFF#E4096 .. 16#0.FFFF_FFFF_FFFF_FFFF#E4096;
   for Long_Long_Float'Size use 128;

The all_silent_tests.adb test runs successfully.


This is with commit 5841f9d.

zertovitch commented 1 year ago

Thanks for the report. Actually you discovered a bunch of issues - ouch! And by looking at the code there is an obvious supplemental one: there is an overflow when the integer scanned before the dot is too large.

zertovitch commented 1 year ago

Commit https://github.com/zertovitch/hac/commit/ae9cc77bc19347fe07fa4d1bbe6d71d6f74210ca should solve the issue. To summarize:

simonjwright commented 1 year ago

Looking good, thanks!

zertovitch commented 1 year ago

So the test works now on your macs and we can close the issue ? (It seems obvious that it should work, but I am a bit superstitious sometimes ;-) ).

simonjwright commented 1 year ago

digitz.adb works. all_silent_tests.adb works.

Closing ...