Bug 127026 - gcc generates bad code in Ada programs when checking the valid attribute
gcc generates bad code in Ada programs when checking the valid attribute
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Depends On:
  Show dependency treegraph
Reported: 2004-06-30 15:34 EDT by Jean Francois Martinez
Modified: 2007-11-30 17:10 EST (History)
0 users

See Also:
Fixed In Version: 3.4.2-6.fc3
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2005-01-03 13:07:02 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Program who checks the Valid attribute on a floating variable (215 bytes, text/plain)
2004-06-30 15:43 EDT, Jean Francois Martinez
no flags Details

  None (edit)
Description Jean Francois Martinez 2004-06-30 15:34:43 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.2)

Description of problem:
I have found that if

a) I compile with -O or -O2 (important)
b) If the variable Myvar is from a type derived from floating then
checking its validity through the Valid attribute (instead
of letting the typing system do it) ever returns false even
when variable has a correct value

If variable is derived from integer or if I compile without
optimization then it yields the correct result

The problem with it is that the package ada.calendar stumbles
on it thus making the time_of  function unusable. 

This bug is specific to gcc 3.3.3.  It is not present in the gcc 3.3.2
shipped with taroon.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. gnatmake -s -02 myprogram.adb
2. ./myprogram (I am attaching a 5 lines program exhibiting this bug)

Actual Results:  The attached program takes the wrong branch in its if
and raises an exception

Expected Results:  Program should have ended silently.  Now do a
gnatmake -s myprogram.adb
and this ti�me program behaves correctly

Additional info:
Comment 1 Jean Francois Martinez 2004-06-30 15:43:22 EDT
Created attachment 101544 [details]
Program who checks the Valid attribute on a floating variable 

Notice that the variable is from a type who is a limited range (0.0 to 86400.0)

If it were a mere float (ie one whose range is determined by the hardware) then
the optimizer would simply remove the check.

As told this program raises an exception (wrongly) if it compiled with -O or
and doesn't when compiled withoput optimization
Comment 2 Jakub Jelinek 2005-01-03 13:07:02 EST
This is fixed in GCC 3.4.2 as shipped in FC3.

Note You need to log in before you can comment on or make changes to this bug.