Bug 127026 - gcc generates bad code in Ada programs when checking the valid attribute
Summary: gcc generates bad code in Ada programs when checking the valid attribute
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: 2
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2004-06-30 19:34 UTC by Jean Francois Martinez
Modified: 2007-11-30 22:10 UTC (History)
0 users

Fixed In Version: 3.4.2-6.fc3
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2005-01-03 18:07:02 UTC
Type: ---
Embargoed:


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

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.


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