public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/21797] New: complex(4) sqrt failures on alpha-linux
@ 2005-05-28 10:46 fxcoudert at gcc dot gnu dot org
  2005-05-28 14:40 ` [Bug fortran/21797] " kargl at gcc dot gnu dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2005-05-28 10:46 UTC (permalink / raw)
  To: gcc-bugs

On alpha-linux, I see the following testsuite failures: 

gfortran.dg/f2c_2.f90
gfortran.dg/g77/cabs.f
gfortran.dg/g77/f90-intrinsic-mathematical.f
gfortran.fortran-torture/execute/csqrt_1.f90
gfortran.fortran-torture/execute/intrinsic_abs.f90
gfortran.fortran-torture/execute/math.f90
gfortran.fortran-torture/execute/power.f90

They all have the same cause: SQRT intrinsic doesn't seem to work on
complex(kind=4):

$ cat a.f90 
  complex(4) c, z
  z = (4.0,0.0)
  c = sqrt(z)
  print *, c
  print *, z, c**2 
  end
$ gfc a.f90 && ./a.out
 ( 1.1603759E-02,  0.000000    )
 (  4.000000    ,  0.000000    ) ( 1.3464721E-04,  0.000000    )

Note that the same code works with complex(8), as well as both real kinds.

I'm willing to investigate that issue, but haven't got any idea what to do.

-- 
           Summary: complex(4) sqrt failures on alpha-linux
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: fxcoudert at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: alphaev67-unknown-linux-gnu
  GCC host triplet: alphaev67-unknown-linux-gnu
GCC target triplet: alphaev67-unknown-linux-gnu


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


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

* [Bug fortran/21797] complex(4) sqrt failures on alpha-linux
  2005-05-28 10:46 [Bug fortran/21797] New: complex(4) sqrt failures on alpha-linux fxcoudert at gcc dot gnu dot org
@ 2005-05-28 14:40 ` kargl at gcc dot gnu dot org
  2005-05-28 16:34 ` sgk at troutmask dot apl dot washington dot edu
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: kargl at gcc dot gnu dot org @ 2005-05-28 14:40 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From kargl at gcc dot gnu dot org  2005-05-28 14:39 -------
FX, 

On i386-*-freebsd, -fdump-tree-original shows

  MAIN__ ()
  {
    complex4 z;
    complex4 c;
    z = __complex__ (4.0e+0, 0.0);
    c = csqrtf (z);

kargl[214] find . -type f | xargs grep csqrtf
./gcc/builtins.def:DEF_C99_BUILTIN        (BUILT_IN_CSQRTF, "csqrtf",
BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING)
./gcc/doc/extend.texi:@findex csqrtf
./gcc/doc/extend.texi:@code{csinhl}, @code{csinh}, @code{csinl}, @code{csin},
@code{csqrtf},
./libstdc++-v3/ChangeLog-2000:  (EXTRA_DIST): Remove csqrt.c and csqrtf.c.
./libstdc++-v3/acinclude.m4:                csqrtf(tmpf);
./libstdc++-v3/configure:                   csqrtf(tmpf);
./libstdc++-v3/include/std/std_complex.h:  __complex_sqrt(__complex__ float __z)
{ return __builtin_csqrtf(__z); }
./libstdc++-v3/ChangeLog-1998:  * math/csqrtf.c: Likewise.
./libstdc++-v3/ChangeLog-1998:  * math/csqrtf.c: Likewise.
./libstdc++-v3/ChangeLog-1999:  * math/csqrtf.c: Likewise.
./libgfortran/generated/exp_c4.c:csqrtf (GFC_COMPLEX_4 z)

If we look through libgfortran/generated/exp_c4.c, we see that csqrtf
mixes float and double C math functions

  if (im == 0.0)
    {
      if (re < 0.0)
        {
          COMPLEX_ASSIGN (v, 0.0, copysignf (sqrtf (-re), im));
        }
      else
        {
          COMPLEX_ASSIGN (v, fabsf (sqrt (re)),
                          copysignf (0.0, im));
        }
    }

Note the sqrt (re) instead of sqrtf (re).


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu dot org


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


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

* [Bug fortran/21797] complex(4) sqrt failures on alpha-linux
  2005-05-28 10:46 [Bug fortran/21797] New: complex(4) sqrt failures on alpha-linux fxcoudert at gcc dot gnu dot org
  2005-05-28 14:40 ` [Bug fortran/21797] " kargl at gcc dot gnu dot org
@ 2005-05-28 16:34 ` sgk at troutmask dot apl dot washington dot edu
  2005-06-02  7:56 ` tkoenig at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: sgk at troutmask dot apl dot washington dot edu @ 2005-05-28 16:34 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From sgk at troutmask dot apl dot washington dot edu  2005-05-28 15:48 -------
Subject: Re:  complex(4) sqrt failures on alpha-linux

On Sat, May 28, 2005 at 02:39:19PM -0000, kargl at gcc dot gnu dot org wrote:
> 
> If we look through libgfortran/generated/exp_c4.c, we see that csqrtf
> mixes float and double C math functions
> 

I think the patch at http://gcc.gnu.org/ml/fortran/2005-05/msg00349.html
will fix this problem.  But, I don't know m4 nor how to regenerate
exp_c4.c from cexp.m4.



-- 


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


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

* [Bug fortran/21797] complex(4) sqrt failures on alpha-linux
  2005-05-28 10:46 [Bug fortran/21797] New: complex(4) sqrt failures on alpha-linux fxcoudert at gcc dot gnu dot org
  2005-05-28 14:40 ` [Bug fortran/21797] " kargl at gcc dot gnu dot org
  2005-05-28 16:34 ` sgk at troutmask dot apl dot washington dot edu
@ 2005-06-02  7:56 ` tkoenig at gcc dot gnu dot org
  2005-06-02  8:04 ` tkoenig at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2005-06-02  7:56 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tkoenig at gcc dot gnu dot org  2005-06-02 07:56 -------
Created an attachment (id=9011)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=9011&action=view)
Proposed patch

This patch fixes the problems noted by Steve Kargl (wrong
types for floating point functions), and also cleans up the m4
style so only variables are unquoted.

-- 


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


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

* [Bug fortran/21797] complex(4) sqrt failures on alpha-linux
  2005-05-28 10:46 [Bug fortran/21797] New: complex(4) sqrt failures on alpha-linux fxcoudert at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2005-06-02  7:56 ` tkoenig at gcc dot gnu dot org
@ 2005-06-02  8:04 ` tkoenig at gcc dot gnu dot org
  2005-06-11 22:43 ` sgk at troutmask dot apl dot washington dot edu
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2005-06-02  8:04 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tkoenig at gcc dot gnu dot
                   |                            |org


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


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

* [Bug fortran/21797] complex(4) sqrt failures on alpha-linux
  2005-05-28 10:46 [Bug fortran/21797] New: complex(4) sqrt failures on alpha-linux fxcoudert at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2005-06-02  8:04 ` tkoenig at gcc dot gnu dot org
@ 2005-06-11 22:43 ` sgk at troutmask dot apl dot washington dot edu
  2005-06-13 16:30 ` fxcoudert at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: sgk at troutmask dot apl dot washington dot edu @ 2005-06-11 22:43 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From sgk at troutmask dot apl dot washington dot edu  2005-06-11 22:43 -------
Subject: Re:  complex(4) sqrt failures on alpha-linux

On Thu, Jun 02, 2005 at 07:56:27AM -0000, tkoenig at gcc dot gnu dot org wrote:
> 
> Created an attachment (id=9011)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=9011&action=view)
>  --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=9011&action=view)
> Proposed patch
> 
> This patch fixes the problems noted by Steve Kargl (wrong
> types for floating point functions), and also cleans up the m4
> style so only variables are unquoted.
> 

I'm not sure if I'm allowed to ok this patch.  But, it is
correct as far as I can tell, so please commit it.



-- 


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


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

* [Bug fortran/21797] complex(4) sqrt failures on alpha-linux
  2005-05-28 10:46 [Bug fortran/21797] New: complex(4) sqrt failures on alpha-linux fxcoudert at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2005-06-11 22:43 ` sgk at troutmask dot apl dot washington dot edu
@ 2005-06-13 16:30 ` fxcoudert at gcc dot gnu dot org
  2005-06-13 19:49 ` [Bug fortran/21797] [4.0 only] " tkoenig at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2005-06-13 16:30 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From fxcoudert at gcc dot gnu dot org  2005-06-13 16:29 -------
Although, unlike Steve, I am sure I'm not allowed to ok this patch, I would
really like to see it go in too. alpha-linux really is an interesting platform
for regtesting (and, moreover, libgfortran will soon be able to build on Tru64
Unix).

-- 


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


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

* [Bug fortran/21797] [4.0 only] complex(4) sqrt failures on alpha-linux
  2005-05-28 10:46 [Bug fortran/21797] New: complex(4) sqrt failures on alpha-linux fxcoudert at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2005-06-13 16:30 ` fxcoudert at gcc dot gnu dot org
@ 2005-06-13 19:49 ` tkoenig at gcc dot gnu dot org
  2005-06-13 20:56 ` fxcoudert at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2005-06-13 19:49 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tkoenig at gcc dot gnu dot org  2005-06-13 19:49 -------
(In reply to comment #5)
> Although, unlike Steve, I am sure I'm not allowed to ok this patch, I would
> really like to see it go in too. alpha-linux really is an interesting platform
> for regtesting (and, moreover, libgfortran will soon be able to build on Tru64
> Unix).

I have committed Steve's patch, commit message is at
http://gcc.gnu.org/ml/gcc-cvs/2005-06/msg00450.html . I don't know why
this didn't appear here.

Looking at

http://gcc.gnu.org/ml/gcc-testresults/2005-06/msg00821.html

it seems that this was indeed fixed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |4.0.1
      Known to work|                            |4.1.0
            Summary|complex(4) sqrt failures on |[4.0 only] complex(4) sqrt
                   |alpha-linux                 |failures on alpha-linux
   Target Milestone|---                         |4.0.2


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


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

* [Bug fortran/21797] [4.0 only] complex(4) sqrt failures on alpha-linux
  2005-05-28 10:46 [Bug fortran/21797] New: complex(4) sqrt failures on alpha-linux fxcoudert at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2005-06-13 19:49 ` [Bug fortran/21797] [4.0 only] " tkoenig at gcc dot gnu dot org
@ 2005-06-13 20:56 ` fxcoudert at gcc dot gnu dot org
  2005-06-14 10:55 ` fxcoudert at gcc dot gnu dot org
  2005-06-16 21:24 ` fxcoudert at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2005-06-13 20:56 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From fxcoudert at gcc dot gnu dot org  2005-06-13 20:56 -------
Now that it is fixed, we can at least CONFIRM it ;-)

As for why the commit message didn't appear it: "PR libfortran/PR21797" seems to
have confused the parsing mechanism for detecting bugs related to commits.

Thanks for committing this.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |patch
   Last reconfirmed|0000-00-00 00:00:00         |2005-06-13 20:56:00
               date|                            |


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


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

* [Bug fortran/21797] [4.0 only] complex(4) sqrt failures on alpha-linux
  2005-05-28 10:46 [Bug fortran/21797] New: complex(4) sqrt failures on alpha-linux fxcoudert at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2005-06-13 20:56 ` fxcoudert at gcc dot gnu dot org
@ 2005-06-14 10:55 ` fxcoudert at gcc dot gnu dot org
  2005-06-16 21:24 ` fxcoudert at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2005-06-14 10:55 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From fxcoudert at gcc dot gnu dot org  2005-06-14 10:55 -------
Well, my latest tests on alphaev67-linux
(http://gcc.gnu.org/ml/gcc-testresults/2005-06/msg00870.html) does not show any
improvement (most failures are due to this problem). What I don't understand is
why rth doesn't have this problem (from
http://gcc.gnu.org/ml/gcc-testresults/2005-06/msg00640.html, you can see that he
didn't have this problem even before the patch was committed).

I don't have much time to look at this now, but generated code looks OK:

$ cat a.f90.t02.original 
MAIN__ ()
{
  complex4 z;
  complex4 c;

  z = __complex__ (4.0e+0, 0.0);
  c = csqrtf (z);

Even using this straight from C works OK with the system compiler:

$ cat a.c 
#include <complex.h>
#include <math.h>

int main (void) {
  complex z;
  z = 4;
  z = csqrtf(z);
  printf ("%g\n",z);
  return 0;
}
$ gcc a.c -lm && ./a.out
2

But it fails if you use the 4.1.0 compiler:

$ ./bin/gcc -static -lm a.c 
a.c: In function 'main':
a.c:8: warning: incompatible implicit declaration of built-in function 'printf'
/tmp/cce9eolp.o: In function `main':
/tmp/cce9eolp.o(.text+0x50): undefined reference to `csqrtf'
collect2: ld returned 1 exit status


-- 


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


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

* [Bug fortran/21797] [4.0 only] complex(4) sqrt failures on alpha-linux
  2005-05-28 10:46 [Bug fortran/21797] New: complex(4) sqrt failures on alpha-linux fxcoudert at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2005-06-14 10:55 ` fxcoudert at gcc dot gnu dot org
@ 2005-06-16 21:24 ` fxcoudert at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2005-06-16 21:24 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From fxcoudert at gcc dot gnu dot org  2005-06-16 21:24 -------
Well, I spoke with rth today on IRC, and it appears that I do have a broken
glibc (in fact, it sounds like most glibc are broken on alpha-linux). So
resolving this one as invalid.

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


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


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

end of thread, other threads:[~2005-06-16 21:24 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-28 10:46 [Bug fortran/21797] New: complex(4) sqrt failures on alpha-linux fxcoudert at gcc dot gnu dot org
2005-05-28 14:40 ` [Bug fortran/21797] " kargl at gcc dot gnu dot org
2005-05-28 16:34 ` sgk at troutmask dot apl dot washington dot edu
2005-06-02  7:56 ` tkoenig at gcc dot gnu dot org
2005-06-02  8:04 ` tkoenig at gcc dot gnu dot org
2005-06-11 22:43 ` sgk at troutmask dot apl dot washington dot edu
2005-06-13 16:30 ` fxcoudert at gcc dot gnu dot org
2005-06-13 19:49 ` [Bug fortran/21797] [4.0 only] " tkoenig at gcc dot gnu dot org
2005-06-13 20:56 ` fxcoudert at gcc dot gnu dot org
2005-06-14 10:55 ` fxcoudert at gcc dot gnu dot org
2005-06-16 21:24 ` fxcoudert 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).