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:
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
This is fixed in GCC 3.4.2 as shipped in FC3.