public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/24875]  New: [gfortran] Arithmetic overflow during compilation
@ 2005-11-15 13:05 martin at mpa-garching dot mpg dot de
  2005-11-15 20:11 ` [Bug fortran/24875] [gfortran, 4.1.0 regression] " kargl at gcc dot gnu dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: martin at mpa-garching dot mpg dot de @ 2005-11-15 13:05 UTC (permalink / raw)
  To: gcc-bugs

The current mainline gfortran aborts compilation with an error for the code
below:

module mod1
implicit none
  integer, parameter :: gndp = kind(1.0d0)
  real(kind = gndp), parameter :: GNDP_MAX = huge(0.0_gndp)
end module mod1

module mod2
use mod1
implicit none

contains

  subroutine foo()
    real(kind = GNDP) :: val
    val = -GNDP_MAX
  end subroutine

end module mod2


~/tmp>gfortran -c -v huge.f90
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /scratch/gcc/configure --quiet
--prefix=/afs/mpa/data/martin/ugcc --enable-languages=c++,fortran
--with-gmp=/afs/mpa/data/martin/mygmp
Thread model: posix
gcc version 4.1.0 20051115 (experimental)
 /afs/mpa/data/martin/ugcc/libexec/gcc/i686-pc-linux-gnu/4.1.0/f951 huge.f90
-quiet -dumpbase huge.f90 -mtune=pentiumpro -auxbase huge -version -o
/tmp/ccjkyE0d.s
GNU F95 version 4.1.0 20051115 (experimental) (i686-pc-linux-gnu)
        compiled by GNU C version 4.1.0 20051115 (experimental).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
 In file huge.f90:15

    val = -GNDP_MAX
                  1
Error: Arithmetic overflow at (1)


I'm not entirely sure that this is a bug, since it could be the case that
-GNDP_MAX cannot be represented as a real(gndp).

But, on the other hand, the following code compiles without problems:

module mod1
implicit none
  integer, parameter :: gndp = kind(1.0d0)
  real(kind = gndp), parameter :: GNDP_MAX = huge(0.0_gndp)

contains

  subroutine foo()
    real(kind = GNDP) :: val
    val = -GNDP_MAX
  end subroutine

end module mod1


-- 
           Summary: [gfortran] Arithmetic overflow during compilation
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: martin at mpa-garching dot mpg dot de
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

* [Bug fortran/24875] [gfortran, 4.1.0 regression] Arithmetic overflow during compilation
  2005-11-15 13:05 [Bug fortran/24875] New: [gfortran] Arithmetic overflow during compilation martin at mpa-garching dot mpg dot de
@ 2005-11-15 20:11 ` kargl at gcc dot gnu dot org
  2005-11-15 20:16 ` janis at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: kargl at gcc dot gnu dot org @ 2005-11-15 20:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from kargl at gcc dot gnu dot org  2005-11-15 20:11 -------
The code works for me on amd64-*-freebsd.  Can
you compile the failing code with -fdump-parse-tree
and post both mod1.mod and the parse-tree?


-- 

kargl at gcc dot gnu dot org changed:

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


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


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

* [Bug fortran/24875] [gfortran, 4.1.0 regression] Arithmetic overflow during compilation
  2005-11-15 13:05 [Bug fortran/24875] New: [gfortran] Arithmetic overflow during compilation martin at mpa-garching dot mpg dot de
  2005-11-15 20:11 ` [Bug fortran/24875] [gfortran, 4.1.0 regression] " kargl at gcc dot gnu dot org
@ 2005-11-15 20:16 ` janis at gcc dot gnu dot org
  2005-11-15 21:09 ` martin at mpa-garching dot mpg dot de
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: janis at gcc dot gnu dot org @ 2005-11-15 20:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from janis at gcc dot gnu dot org  2005-11-15 20:16 -------
It fails on powerpc64-linux with both -m32 and -m64 for current trunk,
4.0 branch, and GCC 4.0.0.  Since it's Fortran 90 code it's not really
a regression.


-- 


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


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

* [Bug fortran/24875] [gfortran, 4.1.0 regression] Arithmetic overflow during compilation
  2005-11-15 13:05 [Bug fortran/24875] New: [gfortran] Arithmetic overflow during compilation martin at mpa-garching dot mpg dot de
                   ` (2 preceding siblings ...)
  2005-11-15 21:09 ` martin at mpa-garching dot mpg dot de
@ 2005-11-15 21:09 ` martin at mpa-garching dot mpg dot de
  2005-11-15 21:16 ` martin at mpa-garching dot mpg dot de
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: martin at mpa-garching dot mpg dot de @ 2005-11-15 21:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from martin at mpa-garching dot mpg dot de  2005-11-15 21:09 -------
(In reply to comment #2)
> It fails on powerpc64-linux with both -m32 and -m64 for current trunk,
> 4.0 branch, and GCC 4.0.0.  Since it's Fortran 90 code it's not really
> a regression.

Well, it worked for me with the current gcc 4.0 branch, so I thought it might
be one. But it seems this is a quite intermittent problem ...


-- 


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


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

* [Bug fortran/24875] [gfortran, 4.1.0 regression] Arithmetic overflow during compilation
  2005-11-15 13:05 [Bug fortran/24875] New: [gfortran] Arithmetic overflow during compilation martin at mpa-garching dot mpg dot de
  2005-11-15 20:11 ` [Bug fortran/24875] [gfortran, 4.1.0 regression] " kargl at gcc dot gnu dot org
  2005-11-15 20:16 ` janis at gcc dot gnu dot org
@ 2005-11-15 21:09 ` martin at mpa-garching dot mpg dot de
  2005-11-15 21:09 ` martin at mpa-garching dot mpg dot de
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: martin at mpa-garching dot mpg dot de @ 2005-11-15 21:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from martin at mpa-garching dot mpg dot de  2005-11-15 21:09 -------
> The code works for me on amd64-*-freebsd.  Can
> you compile the failing code with -fdump-parse-tree
> and post both mod1.mod and the parse-tree?

Will do tomorrow.


-- 


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


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

* [Bug fortran/24875] [gfortran, 4.1.0 regression] Arithmetic overflow during compilation
  2005-11-15 13:05 [Bug fortran/24875] New: [gfortran] Arithmetic overflow during compilation martin at mpa-garching dot mpg dot de
                   ` (3 preceding siblings ...)
  2005-11-15 21:09 ` martin at mpa-garching dot mpg dot de
@ 2005-11-15 21:16 ` martin at mpa-garching dot mpg dot de
  2005-11-15 21:49 ` sgk at troutmask dot apl dot washington dot edu
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: martin at mpa-garching dot mpg dot de @ 2005-11-15 21:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from martin at mpa-garching dot mpg dot de  2005-11-15 21:16 -------
~/tmp>gfortran -c -fdump-parse-tree huge.f90

        Namespace: A-Z: (UNKNOWN 0)
        procedure name = mod1
        symtree: gndp_max  Ambig 0
        symbol gndp_max (REAL 8)(PARAMETER UNKNOWN-INTENT UNKNOWN-ACCESS
UNKNOWN-PROC)
        value: 1.79769313486232e308_8

        symtree: gndp  Ambig 0
        symbol gndp (INTEGER 4)(PARAMETER UNKNOWN-INTENT UNKNOWN-ACCESS
UNKNOWN-PROC)
        value: 8

        symtree: mod1  Ambig 0
        symbol mod1 (UNKNOWN 0)(MODULE UNKNOWN-INTENT UNKNOWN-ACCESS
UNKNOWN-PROC)

        symtree: huge  Ambig 0
        symbol huge (UNKNOWN 0)(PROCEDURE UNKNOWN-INTENT UNKNOWN-ACCESS
UNKNOWN-PROC FUNCTION)
        result: huge

        symtree: kind  Ambig 0
        symbol kind (UNKNOWN 0)(PROCEDURE UNKNOWN-INTENT UNKNOWN-ACCESS
UNKNOWN-PROC FUNCTION)
        result: kind



 In file huge.f90:15

    val = -GNDP_MAX
                  1
Error: Arithmetic overflow at (1)

        Namespace: A-Z: (UNKNOWN 0)
        procedure name = mod2
        symtree: gndp_max  Ambig 0
        symbol gndp_max (REAL 8)(PARAMETER UNKNOWN-INTENT UNKNOWN-ACCESS
UNKNOWN-PROC USE-ASSOC)
        value: 1.79769313486232e308_8

        symtree: gndp  Ambig 0
        symbol gndp (INTEGER 4)(PARAMETER UNKNOWN-INTENT UNKNOWN-ACCESS
UNKNOWN-PROC USE-ASSOC)
        value: 8

        symtree: foo  Ambig 0
        symbol foo (UNKNOWN 0)(PROCEDURE UNKNOWN-INTENT UNKNOWN-ACCESS
MODULE-PROC SUBROUTINE)

        symtree: mod2  Ambig 0
        symbol mod2 (UNKNOWN 0)(MODULE UNKNOWN-INTENT UNKNOWN-ACCESS
UNKNOWN-PROC)

        symtree: kind  Ambig 0
        symbol kind (UNKNOWN 0)(PROCEDURE UNKNOWN-INTENT UNKNOWN-ACCESS
UNKNOWN-PROC USE-ASSOC FUNCTION)
        result: kind

        symtree: huge  Ambig 0
        symbol huge (UNKNOWN 0)(PROCEDURE UNKNOWN-INTENT UNKNOWN-ACCESS
UNKNOWN-PROC USE-ASSOC FUNCTION)
        result: huge

        symtree: mod1  Ambig 0
        symbol mod1 (UNKNOWN 0)(MODULE UNKNOWN-INTENT UNKNOWN-ACCESS
UNKNOWN-PROC USE-ASSOC)



        CONTAINS

          Namespace: A-Z: (UNKNOWN 0)
          procedure name = foo
          symtree: foo  Ambig 0 from namespace mod2
          symtree: val  Ambig 0
          symbol val (REAL 8)(VARIABLE UNKNOWN-INTENT UNKNOWN-ACCESS
UNKNOWN-PROC)




~/tmp>     
~/tmp>cat mod1.mod
GFORTRAN module created from huge.f90 on Tue Nov 15 22:14:38 2005
If you edit this, you'll get what you deserve.

(() () () () () () () () () () () () () () () () () () () ())

()

()

()

()

(2 'gndp' 'mod1' 1 ((PARAMETER UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN) (
INTEGER 4 ()) 0 0 () (CONSTANT (INTEGER 4 ()) 0 '8') () 0 () ())
3 'kind' '(intrinsic)' 1 ((PROCEDURE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN
FUNCTION) (UNKNOWN 0 ()) 0 0 () () 3 () ())
4 'huge' '(intrinsic)' 1 ((PROCEDURE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN
FUNCTION) (UNKNOWN 0 ()) 0 0 () () 4 () ())
5 'mod1' 'mod1' 1 ((MODULE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN) (
UNKNOWN 0 ()) 0 0 () () 0 () ())
6 'gndp_max' 'mod1' 1 ((PARAMETER UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN) (
REAL 8 ()) 0 0 () (CONSTANT (REAL 8 ()) 0 '0.1000000000000@257') () 0 ()
())
)

('gndp_max' 0 6 'gndp' 0 2 'mod1' 0 5 'huge' 0 4 'kind' 0 3)
~/tmp>           


-- 


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


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

* [Bug fortran/24875] [gfortran, 4.1.0 regression] Arithmetic overflow during compilation
  2005-11-15 13:05 [Bug fortran/24875] New: [gfortran] Arithmetic overflow during compilation martin at mpa-garching dot mpg dot de
                   ` (4 preceding siblings ...)
  2005-11-15 21:16 ` martin at mpa-garching dot mpg dot de
@ 2005-11-15 21:49 ` sgk at troutmask dot apl dot washington dot edu
  2006-01-16 11:14 ` martin at mpa-garching dot mpg dot de
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: sgk at troutmask dot apl dot washington dot edu @ 2005-11-15 21:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from sgk at troutmask dot apl dot washington dot edu  2005-11-15 21:49 -------
Subject: Re:  [gfortran, 4.1.0 regression] Arithmetic overflow during
compilation

> Comment #5 from martin
> ~/tmp>gfortran -c -fdump-parse-tree huge.f90
> 
>Namespace: A-Z: (UNKNOWN 0)
>procedure name = mod1
>symtree: gndp_max  Ambig 0
>symbol gndp_max (REAL 8)(PARAMETER UNKNOWN-INTENT UNKNOWN-ACCESS UNKNOWN-PROC)
>value: 1.79769313486232e308_8
> 

On amd64-*-freebsd.

Namespace: A-Z: (UNKNOWN 0)
procedure name = mod1
symtree: gndp_max  Ambig 0
symbol gndp_max (REAL 8)(PARAMETER UNKNOWN-INTENT UNKNOWN-ACCESS UNKNOWN-PROC)
value: 1.7976931348623157e308_8

>procedure name = mod2
>symtree: gndp_max  Ambig 0
>symbol gndp_max (REAL 8)(PARAMETER UNKNOWN-INTENT UNKNOWN-ACCESS
>  UNKNOWN-PROC USE-ASSOC)
>value: 1.79769313486232e308_8

Good, you're reading in what was written to the module.

> 6 'gndp_max' 'mod1' 1 ((PARAMETER UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN) (
> REAL 8 ()) 0 0 () (CONSTANT (REAL 8 ()) 0 '0.1000000000000@257') () 0 ()
> ())

6 'gndp_max' 'mod1' 1 ((PARAMETER UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN) (
REAL 8 ()) 0 0 () (CONSTANT (REAL 8 ()) 0 '0.fffffffffffff8@256') () 0 ()

Hmmm, this doesn't look good.  You're getting 1 fewer digits
than I.  I'll check what happens on i386-*-freebsd.


-- 


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


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

* [Bug fortran/24875] [gfortran, 4.1.0 regression] Arithmetic overflow during compilation
  2005-11-15 13:05 [Bug fortran/24875] New: [gfortran] Arithmetic overflow during compilation martin at mpa-garching dot mpg dot de
                   ` (5 preceding siblings ...)
  2005-11-15 21:49 ` sgk at troutmask dot apl dot washington dot edu
@ 2006-01-16 11:14 ` martin at mpa-garching dot mpg dot de
  2006-01-20 20:56 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: martin at mpa-garching dot mpg dot de @ 2006-01-16 11:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from martin at mpa-garching dot mpg dot de  2006-01-16 11:14 -------
I have re-tested today, and it seems that the problem only occurs when gfortran
is built using a self-compiled version of GMP 4.1.3. When using the system-wide
installed GMP 4.1.4 I don't get the error.
So this looks like a GMP-related problem (either a bug in GMP or a
miscompilation
of GMP).


-- 


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


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

* [Bug fortran/24875] [gfortran, 4.1.0 regression] Arithmetic overflow during compilation
  2005-11-15 13:05 [Bug fortran/24875] New: [gfortran] Arithmetic overflow during compilation martin at mpa-garching dot mpg dot de
                   ` (6 preceding siblings ...)
  2006-01-16 11:14 ` martin at mpa-garching dot mpg dot de
@ 2006-01-20 20:56 ` pinskia at gcc dot gnu dot org
  2006-01-21  8:49 ` martin at mpa-garching dot mpg dot de
  2006-01-21 17:27 ` sgk at troutmask dot apl dot washington dot edu
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-01-20 20:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from pinskia at gcc dot gnu dot org  2006-01-20 20:56 -------
I am going to declare this is GMP bug as I can reproduce it on two out of three
of my machines.  The one with the newest GMP, it works.  These three machines
are all different targets, powerpc, x86 and x86-64.

So closing as worksforme.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |WORKSFORME


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


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

* [Bug fortran/24875] [gfortran, 4.1.0 regression] Arithmetic overflow during compilation
  2005-11-15 13:05 [Bug fortran/24875] New: [gfortran] Arithmetic overflow during compilation martin at mpa-garching dot mpg dot de
                   ` (7 preceding siblings ...)
  2006-01-20 20:56 ` pinskia at gcc dot gnu dot org
@ 2006-01-21  8:49 ` martin at mpa-garching dot mpg dot de
  2006-01-21 17:27 ` sgk at troutmask dot apl dot washington dot edu
  9 siblings, 0 replies; 11+ messages in thread
From: martin at mpa-garching dot mpg dot de @ 2006-01-21  8:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from martin at mpa-garching dot mpg dot de  2006-01-21 08:49 -------
(In reply to comment #8)
> I am going to declare this is GMP bug as I can reproduce it on two out of three
> of my machines.  The one with the newest GMP, it works.  These three machines
> are all different targets, powerpc, x86 and x86-64.

Unfortunately I can reproduce it with GMP 4.1.4 now :(
This is on an Athlon64 with Suse 10.0, using the GMP 4.1.4 coming with the
distribution.

What do we do?

BTW, the GMP people have a big notice on their web page that recent gcc
versions often miscompile GMP. That could of course be a problem of the GMP
code as well, but maybe the GMP testsuite should be used regularly to test GCC
builds.
This is especially important since gfortran relies on GMP and MPFR working
properly.


-- 


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


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

* [Bug fortran/24875] [gfortran, 4.1.0 regression] Arithmetic overflow during compilation
  2005-11-15 13:05 [Bug fortran/24875] New: [gfortran] Arithmetic overflow during compilation martin at mpa-garching dot mpg dot de
                   ` (8 preceding siblings ...)
  2006-01-21  8:49 ` martin at mpa-garching dot mpg dot de
@ 2006-01-21 17:27 ` sgk at troutmask dot apl dot washington dot edu
  9 siblings, 0 replies; 11+ messages in thread
From: sgk at troutmask dot apl dot washington dot edu @ 2006-01-21 17:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from sgk at troutmask dot apl dot washington dot edu  2006-01-21 17:27 -------
Subject: Re:  [gfortran, 4.1.0 regression] Arithmetic overflow during
compilation

On Sat, Jan 21, 2006 at 08:49:26AM -0000, martin at mpa-garching dot mpg dot de
wrote:
> 
> Unfortunately I can reproduce it with GMP 4.1.4 now :(
> This is on an Athlon64 with Suse 10.0, using the GMP 4.1.4 coming with the
> distribution.
> 
> What do we do?
> 

Contact SuSe.  This isn't a gfortran problem.


-- 


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


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

end of thread, other threads:[~2006-01-21 17:27 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-15 13:05 [Bug fortran/24875] New: [gfortran] Arithmetic overflow during compilation martin at mpa-garching dot mpg dot de
2005-11-15 20:11 ` [Bug fortran/24875] [gfortran, 4.1.0 regression] " kargl at gcc dot gnu dot org
2005-11-15 20:16 ` janis at gcc dot gnu dot org
2005-11-15 21:09 ` martin at mpa-garching dot mpg dot de
2005-11-15 21:09 ` martin at mpa-garching dot mpg dot de
2005-11-15 21:16 ` martin at mpa-garching dot mpg dot de
2005-11-15 21:49 ` sgk at troutmask dot apl dot washington dot edu
2006-01-16 11:14 ` martin at mpa-garching dot mpg dot de
2006-01-20 20:56 ` pinskia at gcc dot gnu dot org
2006-01-21  8:49 ` martin at mpa-garching dot mpg dot de
2006-01-21 17:27 ` sgk at troutmask dot apl dot washington dot edu

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).