Bug 107391 - internal error on decimal literal with huge exponent
Summary: internal error on decimal literal with huge exponent
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: ada (show other bugs)
Version: 12.2.1
: P3 normal
Target Milestone: 16.0
Assignee: Eric Botcazou
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-10-25 11:38 UTC by jwaldmann
Modified: 2026-04-17 20:31 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2022-10-29 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jwaldmann 2022-10-25 11:38:21 UTC
$ echo "procedure main is x : float := 1.1e11111111111111111111; begin null; end main;" > main.adb

$ gcc -c main.adb 
+===========================GNAT BUG DETECTED==============================+
| 12.2.1 20220819 (Red Hat 12.2.1-2) (x86_64-redhat-linux) Constraint_Error uintp.adb:2287 explicit raise|
| Error detected at main.adb:1:32                                          |
| Compiling main.adb                                                       |
| Please submit a bug report; see https://gcc.gnu.org/bugs/ .              |

$ gcc --version
gcc (GCC) 12.2.1 20220819 (Red Hat 12.2.1-2)


with up to ten digits in the exponent, I get the expected

$ echo "procedure main is x : float := 1.1e11111_11111; begin null; end main;" > main.adb

$ gcc -c main.adb 
main.adb:1:32: error: value not in range of type "Standard.Float"
main.adb:1:32: error: static expression fails Constraint_Check
Comment 1 Eric Botcazou 2022-10-29 11:46:05 UTC
That's really a large number.
Comment 2 Eric Botcazou 2026-04-17 08:57:12 UTC
Fixing.
Comment 3 GCC Commits 2026-04-17 20:28:56 UTC
The master branch has been updated by Eric Botcazou <ebotcazou@gcc.gnu.org>:

https://gcc.gnu.org/g:a3fae6393c63c09cfb57f03a3a8faf5fc33e0961

commit r16-8742-ga3fae6393c63c09cfb57f03a3a8faf5fc33e0961
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Fri Apr 17 22:22:07 2026 +0200

    Ada: Fix internal error on decimal literal with huge exponent
    
    This is a serious contender for the smallest chunk of code still crashing
    the compiler after three decades.
    
    gcc/ada/
            PR ada/107391
            * urealp.adb (Decimal_Exponent_Hi): Check that the denominator is
            in range before invoking UI_To_Int on it, and cope with failure.
            (Decimal_Exponent_Lo): Likewise.
    
    gcc/testsuite/
            * gnat.dg/specs/float_literal1.ads: New test.
Comment 4 Eric Botcazou 2026-04-17 20:31:02 UTC
Fixed on the mainline.