[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#844036: marked as done (gfortran-6: spits out false warning about COMPLEX(4) to REAL(4) conversion when using a complex parameter)



Your message dated Thu, 17 Nov 2016 12:52:10 +0100
with message-id <90fbe9da-578f-5996-859f-995d43e10b94@debian.org>
and subject line Re: Bug#844036: gfortran-6: spits out false warning about COMPLEX(4) to REAL(4) conversion when using a complex parameter
has caused the Debian Bug report #844036,
regarding gfortran-6: spits out false warning about COMPLEX(4) to REAL(4) conversion when using a complex parameter
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
844036: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=844036
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems
--- Begin Message ---
Package: gfortran-6
Version: 6.2.0-10
Severity: normal

Hello,
I think I found a bug in gfortran.

Please consider the following simple program:

  $ cat cpxparam.f 
        program main
  
        complex iu
        parameter (iu=(0,1))
  
        complex val1,val2
  
        write (*,*) 'iu = ',iu
  
        val1 = (+2.0,+3.0)
        val2 = (+4.0,-1.0)
  
  c     the following should write (2 + j3)/(j*(4 - j) = (14 - j*5)/17
  c     that is to say about  (0.8235294 , -0.2941176)
        write (*,*) val1/(iu*val2)
  
        end

If I try to compile this with the following command line:

  $ gfortran -pedantic -Wall -fimplicit-none -o cpxparam cpxparam.f
  cpxparam.f:4:20:
  
         parameter (iu=(0,1))
                      1
  Warning: Non-zero imaginary part discarded in conversion from ‘COMPLEX(4)’ to ‘REAL(4)’ at (1) [-Wconversion]

I get the above-quoted scary warning about an unintended conversion of
iu to real type!!!
But this conversion seems to never take place (luckily):

  $ ./cpxparam
   iu =  (  0.00000000    ,  1.00000000    )
   ( 0.823529422    ,-0.294117659    )

As you can see, the output is the expected one.

At first I thought a recent gfortran could maybe have some issues
in dealing with the old Fortran77-style syntax.
So, let's try with some more modern style:

  $ cat cpxparam_modern.f 
        program main
  
        complex,parameter :: iu=(0,1)
  
        complex :: val1,val2
  
        write (*,*) 'iu = ',iu
  
        val1 = (+2.0,+3.0)
        val2 = (+4.0,-1.0)
  
  c     the following should write (2 + j3)/(j*(4 - j) = (14 - j*5)/17
  c     that is to say about  (0.8235294 , -0.2941176)
        write (*,*) val1/(iu*val2)
  
        end

Same story:

  $ gfortran -pedantic -Wall -fimplicit-none -o cpxparam_modern cpxparam_modern.f 
  cpxparam_modern.f:3:30:
  
         complex,parameter :: iu=(0,1)
                                1
  Warning: Non-zero imaginary part discarded in conversion from ‘COMPLEX(4)’ to ‘REAL(4)’ at (1) [-Wconversion]
  $ ./cpxparam_modern 
   iu =  (  0.00000000    ,  1.00000000    )
   ( 0.823529422    ,-0.294117659    )

The scary warning is still produced and the executable output is still
correct, despite the compile-time warning.


Curiously, changing the last expression to be evaluated into a
different, but mathematically equivalent one makes the warning go
away:

  $ cat cpxparam2.f 
        program main
  
        complex iu
        parameter (iu=(0,1))
  
        complex val1,val2
  
        write (*,*) 'iu = ',iu
  
        val1 = (+2.0,+3.0)
        val2 = (+4.0,-1.0)
  
  c     the following should write (2 + j3)/(j*(4 - j) = (14 - j*5)/17
  c     that is to say about  (0.8235294 , -0.2941176)
        write (*,*) -iu*val1/val2
  
        end
  $ gfortran -pedantic -Wall -fimplicit-none -o cpxparam2 cpxparam2.f
  $ ./cpxparam2 
   iu =  (  0.00000000    ,  1.00000000    )
   ( 0.823529422    ,-0.294117659    )

No warning and correct output from the compiled program.


Please investigate this bug and/or forward my bug report upstream,
as appropriate.

Thanks for your time!
Bye.


P.S.: the above-quoted simple programs are probably trivial enough to
not be copyrighted; in case this turns out to be false, I hereby
release them under the terms of the Expat license
<http://www.jclark.com/xml/copying.txt>


-- System Information:
Debian Release: stretch/sid
  APT prefers testing
  APT policy: (800, 'testing'), (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 4.7.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages gfortran-6 depends on:
ii  gcc-6              6.2.0-10
ii  gcc-6-base         6.2.0-10
ii  libc6              2.24-5
ii  libc6-dev          2.24-5
ii  libgfortran-6-dev  6.2.0-10
ii  libgmp10           2:6.1.1+dfsg-1
ii  libisl15           0.17.1-1
ii  libmpc3            1.0.3-1
ii  libmpfr4           3.1.5-1
ii  zlib1g             1:1.2.8.dfsg-2+b3

gfortran-6 recommends no packages.

Versions of packages gfortran-6 suggests:
pn  gfortran-6-doc       <none>
pn  gfortran-6-multilib  <none>
pn  libcoarrays-dev      <none>
pn  libgfortran3-dbg     <none>

-- no debconf information

--- End Message ---
--- Begin Message ---
Version: 6.2.0-13

Fixed at least in 6.2.0-13

--- End Message ---

Reply to: