public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/14396] New: [gfortran] Intrinsic SQRT and CSQRT give wrong answer with COMPLEX argument.
@ 2004-03-03  4:41 bdavis9659 at comcast dot net
  2004-03-03  4:56 ` [Bug fortran/14396] " pinskia at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: bdavis9659 at comcast dot net @ 2004-03-03  4:41 UTC (permalink / raw)
  To: gcc-bugs

Distilled from test FM833 of the NIST F77 compiler validation suite.

        COMPLEX BVC,AVC
        BVC = (3.0, 4.0)
        AVC = CSQRT(BVC) - SQRT(BVC)
        print*,'CSQRT(BVC)=',CSQRT(BVC),' SQRT(BVC)=',SQRT(BVC)
        print*,'CSQRT(BVC) - SQRT(BVC)',avc
        end
 
 
$ /usr/local/bin/gfortran -static z.f
$ ./a.out
CSQRT(BVC)= ( NaN,   0.000000    )  SQRT(BVC)= ( NaN,   0.000000    )
CSQRT(BVC) - SQRT(BVC) ( NaN,   0.000000    )


Same code with g77:

$ g77 z.f
$ ./a.out
 CSQRT(BVC)= (2.,1.) SQRT(BVC)= (2.,1.)
 CSQRT(BVC) - SQRT(BVC) (0.,0.)

-- 
           Summary: [gfortran] Intrinsic SQRT and CSQRT give wrong answer
                    with COMPLEX argument.
           Product: gcc
           Version: tree-ssa
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bdavis9659 at comcast dot net
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14396


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug fortran/14396] [gfortran] Intrinsic SQRT and CSQRT give wrong answer with COMPLEX argument.
  2004-03-03  4:41 [Bug fortran/14396] New: [gfortran] Intrinsic SQRT and CSQRT give wrong answer with COMPLEX argument bdavis9659 at comcast dot net
@ 2004-03-03  4:56 ` pinskia at gcc dot gnu dot org
  2004-03-03  4:59 ` bdavis9659 at comcast dot net
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-03-03  4:56 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-03-03 04:56 -------
With 20040208, I get the correct result (but this on powerpc-apple-darwin):
[zhivago2:~/src/gccPRs] pinskia% ./a.out
CSQRT(BVC)= (   2.000000    ,   1.000000    )  SQRT(BVC)= (   2.000000    ,   1.000000    )
CSQRT(BVC) - SQRT(BVC) (   0.000000    ,   0.000000    )

It looks right to me:
  bvc = __complex__ (3.0e+0, 4.0e+0);
  avc = csqrtf (bvc) - csqrtf (bvc);

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
   Target Milestone|---                         |tree-ssa


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14396


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug fortran/14396] [gfortran] Intrinsic SQRT and CSQRT give wrong answer with COMPLEX argument.
  2004-03-03  4:41 [Bug fortran/14396] New: [gfortran] Intrinsic SQRT and CSQRT give wrong answer with COMPLEX argument bdavis9659 at comcast dot net
  2004-03-03  4:56 ` [Bug fortran/14396] " pinskia at gcc dot gnu dot org
@ 2004-03-03  4:59 ` bdavis9659 at comcast dot net
  2004-03-04 12:48 ` wf_cs at yahoo dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: bdavis9659 at comcast dot net @ 2004-03-03  4:59 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bdavis9659 at comcast dot net  2004-03-03 04:59 -------
Original problem observed on i386 / linux.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14396


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug fortran/14396] [gfortran] Intrinsic SQRT and CSQRT give wrong answer with COMPLEX argument.
  2004-03-03  4:41 [Bug fortran/14396] New: [gfortran] Intrinsic SQRT and CSQRT give wrong answer with COMPLEX argument bdavis9659 at comcast dot net
  2004-03-03  4:56 ` [Bug fortran/14396] " pinskia at gcc dot gnu dot org
  2004-03-03  4:59 ` bdavis9659 at comcast dot net
@ 2004-03-04 12:48 ` wf_cs at yahoo dot com
  2004-03-04 16:14 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: wf_cs at yahoo dot com @ 2004-03-04 12:48 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From wf_cs at yahoo dot com  2004-03-04 12:48 -------
The test is also passed on i686-pc-linux-gnu and ia64-unknow-linux-gnu.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14396


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug fortran/14396] [gfortran] Intrinsic SQRT and CSQRT give wrong answer with COMPLEX argument.
  2004-03-03  4:41 [Bug fortran/14396] New: [gfortran] Intrinsic SQRT and CSQRT give wrong answer with COMPLEX argument bdavis9659 at comcast dot net
                   ` (2 preceding siblings ...)
  2004-03-04 12:48 ` wf_cs at yahoo dot com
@ 2004-03-04 16:14 ` pinskia at gcc dot gnu dot org
  2004-03-06  4:14 ` [Bug libfortran/14396] " pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-03-04 16:14 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-03-04 16:14 -------
Can you try again (maybe without -static)?  It might be a bug in you math library.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14396


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libfortran/14396] [gfortran] Intrinsic SQRT and CSQRT give wrong answer with COMPLEX argument.
  2004-03-03  4:41 [Bug fortran/14396] New: [gfortran] Intrinsic SQRT and CSQRT give wrong answer with COMPLEX argument bdavis9659 at comcast dot net
                   ` (3 preceding siblings ...)
  2004-03-04 16:14 ` pinskia at gcc dot gnu dot org
@ 2004-03-06  4:14 ` pinskia at gcc dot gnu dot org
  2004-03-06 19:37 ` bdavis9659 at comcast dot net
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-03-06  4:14 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-03-06 04:14 -------
The problem comes from libgfortran's csqrt which is not used always (for targets with C99 math 
functions it is not used at all, I do not have a list of targets which have C99 math functions and which 
do not):

>From bud davis:
/* sqrt(z).  Algorithm pulled from glibc.  */
GFC_COMPLEX_4
csqrtf (GFC_COMPLEX_4 z)
{
 GFC_REAL_4 re;
 GFC_REAL_4 im;
 GFC_COMPLEX_4 v;
                                                                               
 re = REALPART (re);   <--- should be z
 im = IMAGPART (im);  <--- should be z

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |NEW
          Component|fortran                     |libfortran
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-03-06 04:14:44
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14396


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libfortran/14396] [gfortran] Intrinsic SQRT and CSQRT give wrong answer with COMPLEX argument.
  2004-03-03  4:41 [Bug fortran/14396] New: [gfortran] Intrinsic SQRT and CSQRT give wrong answer with COMPLEX argument bdavis9659 at comcast dot net
                   ` (4 preceding siblings ...)
  2004-03-06  4:14 ` [Bug libfortran/14396] " pinskia at gcc dot gnu dot org
@ 2004-03-06 19:37 ` bdavis9659 at comcast dot net
  2004-03-24 11:57 ` cvs-commit at gcc dot gnu dot org
  2004-03-24 16:02 ` pinskia at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: bdavis9659 at comcast dot net @ 2004-03-06 19:37 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bdavis9659 at comcast dot net  2004-03-06 19:37 -------
proposed patch submitted to gcc-patches:

http://gcc.gnu.org/ml/fortran/2004-03/msg00007.html

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14396


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libfortran/14396] [gfortran] Intrinsic SQRT and CSQRT give wrong answer with COMPLEX argument.
  2004-03-03  4:41 [Bug fortran/14396] New: [gfortran] Intrinsic SQRT and CSQRT give wrong answer with COMPLEX argument bdavis9659 at comcast dot net
                   ` (5 preceding siblings ...)
  2004-03-06 19:37 ` bdavis9659 at comcast dot net
@ 2004-03-24 11:57 ` cvs-commit at gcc dot gnu dot org
  2004-03-24 16:02 ` pinskia at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-03-24 11:57 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-03-24 11:57 -------
Subject: Bug 14396

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	tree-ssa-20020619-branch
Changes by:	pbrook@gcc.gnu.org	2004-03-24 11:57:40

Modified files:
	gcc/testsuite  : ChangeLog.tree-ssa 
	libgfortran    : ChangeLog 
	libgfortran/generated: exp_c4.c exp_c8.c 
	libgfortran/m4 : cexp.m4 

Log message:
	PR 14396
	* m4/cexp.m4 (csqrt): Actually use the passed value.
	* generated/exp_c?.c: Regenerate.
	testsuite
	* gfortran.fortran-torture/execute/csqrt_1.f90: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.tree-ssa.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=1.1.2.197&r2=1.1.2.198
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/ChangeLog.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=1.1.2.32&r2=1.1.2.33
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/generated/exp_c4.c.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=1.1.2.3&r2=1.1.2.4
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/generated/exp_c8.c.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=1.1.2.3&r2=1.1.2.4
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/m4/cexp.m4.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=1.1.2.2&r2=1.1.2.3



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14396


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libfortran/14396] [gfortran] Intrinsic SQRT and CSQRT give wrong answer with COMPLEX argument.
  2004-03-03  4:41 [Bug fortran/14396] New: [gfortran] Intrinsic SQRT and CSQRT give wrong answer with COMPLEX argument bdavis9659 at comcast dot net
                   ` (6 preceding siblings ...)
  2004-03-24 11:57 ` cvs-commit at gcc dot gnu dot org
@ 2004-03-24 16:02 ` pinskia at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-03-24 16:02 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-03-24 16:01 -------
Fixed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14396


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2004-03-24 16:01 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-03  4:41 [Bug fortran/14396] New: [gfortran] Intrinsic SQRT and CSQRT give wrong answer with COMPLEX argument bdavis9659 at comcast dot net
2004-03-03  4:56 ` [Bug fortran/14396] " pinskia at gcc dot gnu dot org
2004-03-03  4:59 ` bdavis9659 at comcast dot net
2004-03-04 12:48 ` wf_cs at yahoo dot com
2004-03-04 16:14 ` pinskia at gcc dot gnu dot org
2004-03-06  4:14 ` [Bug libfortran/14396] " pinskia at gcc dot gnu dot org
2004-03-06 19:37 ` bdavis9659 at comcast dot net
2004-03-24 11:57 ` cvs-commit at gcc dot gnu dot org
2004-03-24 16:02 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).