[Bug tree-optimization/77648] [5/6 Regression] Setting conversion to a integer to double to 0 3/4 through a loop

2016-09-21 Thread raynman4451 at tamu dot edu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77648

--- Comment #10 from Raymond Fontenot  ---
Yeah I'll see what I can do about simplifying the test case.
~Raymond

[Bug fortran/77648] Setting conversion to a integer to double to 0 3/4 through a loop

2016-09-19 Thread raynman4451 at tamu dot edu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77648

--- Comment #2 from Raymond Fontenot  ---
Created attachment 39650
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=39650=edit
Test Case for Bug

I've attached a test case for this. The code will produce the incorrect
polynomial function p at the end of the routine for the given parameters. The
code will generate the following polynomial (a 1D Wendland function):
  -0.352E-01
   0.000E+00 x  
   0.446E-01 x^ 2   
   0.000E+00 x^ 3   
  -0.298E-02 x^ 4   
   0.000E+00 x^ 5   
   0.208E-01 x^ 6   
  -0.476E-01 x^ 7   
   0.521E-01 x^ 8   
  -0.317E-01 x^ 9   
   0.000E+00 x^10   
   0.000E+00 x^11  

The correct output from the code should be:
 -0.451E-04
   0.000E+00 x  
   0.496E-03 x^ 2   
   0.000E+00 x^ 3   
  -0.298E-02 x^ 4   
   0.000E+00 x^ 5   
   0.208E-01 x^ 6   
  -0.476E-01 x^ 7   
   0.521E-01 x^ 8   
  -0.317E-01 x^ 9   
   0.104E-01 x^10   
  -0.144E-02 x^11   

The bug in question happens in the function (in poly_module.f90)
integrate_poly_indefinite, called in generate_wendland.f90.

[Bug fortran/77648] New: Setting conversion to a integer to double to 0 3/4 through a loop

2016-09-19 Thread raynman4451 at tamu dot edu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77648

Bug ID: 77648
   Summary: Setting conversion to a integer to double to 0 3/4
through a loop
   Product: gcc
   Version: 5.3.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: fortran
  Assignee: unassigned at gcc dot gnu.org
  Reporter: raynman4451 at tamu dot edu
  Target Milestone: ---

Howdy,
I am using gfortran 5.3.1 on OSX 10.11. My code is compiled with -m64 -O3
-fdefault-real-8 -fdefault-double-8, and when compiled for debugging  -m64
-fdefault-real-8 -fdefault-double-8 -fcheck=all -fbacktrace
-ffpe-trap=zero,underflow,denormal,invalid -g) does not throw any errors.
Additionally, I have statically debugged with FORCHECK. My issue is as follows.
Take the following block of code which updates the coefficients of a polynomial
type after integration:

  p_int%coefficients(0) = 0.0d0
  do i = 0, p%order
   p_int%coefficients(i+1) = 1.0d0/dble(i+1)*p%coefficients(i)
  end do

For both Intel and Absoft compilers using similar options, that loop works just
fine, and the conversion of integer to a double is ok. For gfortran, however,
1.0d0/dble(i+1) will equal 0 roughly 3/4 though the number of steps in the
loop. So, if p%order = 7, at about 5 gfortran makes that factor 0. It does not
do this if I place a write statement for 1.0d0/dble(i+1) in the loop, nor does
it do it when the debug options are thrown. To get around it, I had to change
the above block of code to the following:  

   fac = 0.0d0
   do i = 0, p%order
   fac = fac + 1.0d0
   p_int%coefficients(i+1) = p%coefficients(i)/fac
end do

which avoids the conversion altogether.