Bug 127026

Summary: gcc generates bad code in Ada programs when checking the valid attribute
Product: [Fedora] Fedora Reporter: Jean Francois Martinez <jfm512>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 2   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: 3.4.2-6.fc3 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-01-03 18:07:02 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Program who checks the Valid attribute on a floating variable none

Description Jean Francois Martinez 2004-06-30 19:34:43 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.2)
Gecko/20040301

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):
gcc-gnat-3.3.3-7

How reproducible:
Always

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

Actual Results:  The attached program takes the wrong branch in its if
condition
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 19:43:22 UTC
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
-O2
and doesn't when compiled withoput optimization

Comment 2 Jakub Jelinek 2005-01-03 18:07:02 UTC
This is fixed in GCC 3.4.2 as shipped in FC3.