https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79710
Bug ID: 79710 Summary: Assert of a static fixed point expression incorrectly fails Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ada Assignee: unassigned at gcc dot gnu.org Reporter: georggcc at googlemail dot com Target Milestone: --- The program below triggers an unexpected Assert failure of a static expression. The same static expression occurs identically in the same region and is accepted there (see Test constant). The Assert failure can, however, be "prevented" by uncommenting another Assert of another static expression before it that involves the same type and number. The diagnostic messages change accordingly, too. with Ada.Text_IO; procedure Bug_FxP is Shoe_Ounce : constant := 2.54/64.0; type FxP is delta Shoe_Ounce range 0.00 .. 0.32 with Size => 16, Small => 2.0**(-15); -- -- Remove the comments to make the Assert _after_ this one not -- raise (and no other Assert raise either, as expected): -- -- pragma Assert -- (3276 * FxP'Small = 0.0999755859375); pragma Assert -- Fails .IFF. the assertion aboved it stays commented out! (FxP'(0.1) = 0.0999755859375); Test : constant := (case True is when False => 0, when FxP'(0.1) = 0.0999755859375 => 1); package FIO is new Ada.Text_IO.Fixed_IO (Fxp); begin Ada.Text_IO.Put (Test'Img); FIO.Put (Fxp'(0.1), Aft => 20); end; $ gnatmake -gnata -gnatwa -gnatv -f bug_fxp.adb gcc -c -gnata -gnatwa -gnatv bug_fxp.adb GNAT 7.0.0 20161104 (experimental) [trunk revision 241862] Copyright 1992-2016, Free Software Foundation, Inc. Compiling: bug_fxp.adb Source file time stamp: 2017-02-25 11:53:54 Compiled at: 2017-02-25 12:54:01 19. (FxP'(0.1) = 0.0999755859375); 1 2 >>> warning: assertion will fail at run time >>> warning: static fixed-point value is not a multiple of Small 24. when FxP'(0.1) = 0.0999755859375 => 1); | >>> warning: static fixed-point value is not a multiple of Small 29. FIO.Put (Fxp'(0.1), Aft => 20); | >>> warning: static fixed-point value is not a multiple of Small 30 lines: No errors, 4 warnings gnatbind -x bug_fxp.ali gnatlink bug_fxp.ali $ ./bug_fxp raised SYSTEM.ASSERTIONS.ASSERT_FAILURE : bug_fxp.adb:19 $ When I remove the comments from the first Assert on line 15, the one before line 19, the program runs without failure: $ ./bug_fxp 1 0.09997558593750000000 $