gfortran or tree-ssa bug?
Steve Kargl
sgk@troutmask.apl.washington.edu
Sun Apr 4 23:35:00 GMT 2004
On Sun, Apr 04, 2004 at 12:26:25PM -0700, Steve Kargl wrote:
> >
> > This is PR14059
> >
>
> See the following patch. I do not currently have a copyright
> assignment for GCC, but this patch probably falls under the
> "small patch without assignment category". Note, I added a
> gfc_option.warn_underflow option, but did not include a patch
> for gcc/options to define -Wunderflow.
>
> kargl[249] ../../bin/gfortran -o b -static b.f90
> kargl[250] ./b
> x = 0.000000
> y = ( 0.000000 , 0.000000 )
> kargl[251] ../../bin/gfortran -o b -static -Wall b.f90
> In file b.f90:5
>
> x = sqrt(9.125)**2 - 9.125
> 1
> Warning: Arithmetic underflow at (1)
> In file b.f90:6
>
> y = cabs(cexp((-2.5, 1.375))) - exp(5.0 / (-2.0))
> 1
> Warning: Arithmetic underflow at (1)
>
> Changelog
>
> * gfortran.h (struct gfc_option_t): Add gfc_option.warn_underflow.
> * options.c (gfc_init.options, gfc_handle_option): Use it.
> * arith.c (eval_intrinsic): Use it.
> * arith.c: typos in comments.
Nothing like replying to oneself. New patch attached.
Changelog
* gfortran.h (struct gfc_option_t): Add gfc_option.warn_underflow.
* options.c (gfc_init.options, gfc_handle_option): Use it.
* lang.opt: define -Wunderflow
* arith.c (eval_intrinsic): Use it.
* arith.c, misc.c: typos in comments.
--
steve
-------------- next part --------------
Index: arith.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/Attic/arith.c,v
retrieving revision 1.1.2.4
diff -u -u -r1.1.2.4 arith.c
--- arith.c 24 Mar 2004 11:14:07 -0000 1.1.2.4
+++ arith.c 4 Apr 2004 21:51:44 -0000
@@ -1130,7 +1130,7 @@
/* Make sure a constant numeric expression is within the range for
- it's type and kind. Note that there's also a gfc_check_range(),
+ its type and kind. Note that there's also a gfc_check_range(),
but that one deals with the intrinsic RANGE function. */
arith
@@ -2173,8 +2173,12 @@
if (rc != ARITH_OK)
{ /* Something went wrong */
- gfc_error ("%s at %L", gfc_arith_error (rc), &op1->where);
- return NULL;
+ if (rc != ARITH_UNDERFLOW) {
+ gfc_error ("%s at %L", gfc_arith_error (rc), &op1->where);
+ return NULL;
+ } else if (gfc_option.warn_underflow == 1)
+ gfc_warning ("%s at %L", gfc_arith_error (rc), &op1->where);
+ goto runtime;
}
gfc_free_expr (op1);
Index: gfortran.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/Attic/gfortran.h,v
retrieving revision 1.1.2.11
diff -u -u -r1.1.2.11 gfortran.h
--- gfortran.h 4 Apr 2004 15:33:41 -0000 1.1.2.11
+++ gfortran.h 4 Apr 2004 21:51:45 -0000
@@ -1220,6 +1220,7 @@
int warn_implicit_interface;
int warn_line_truncation;
int warn_surprising;
+ int warn_underflow;
int warn_unused_labels;
int flag_dollar_ok;
Index: lang.opt
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/Attic/lang.opt,v
retrieving revision 1.1.2.8
diff -u -u -r1.1.2.8 lang.opt
--- lang.opt 4 Apr 2004 15:33:41 -0000 1.1.2.8
+++ lang.opt 4 Apr 2004 21:51:45 -0000
@@ -57,6 +57,10 @@
F95
Warn about \"suspicious\" constructs
+Wunderflow
+F95
+Warn about underflow of numeric constants
+
Wunused-labels
F95
Warn when a label is unused
Index: misc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/Attic/misc.c,v
retrieving revision 1.1.2.1
diff -u -u -r1.1.2.1 misc.c
--- misc.c 26 Jul 2003 16:27:46 -0000 1.1.2.1
+++ misc.c 4 Apr 2004 21:51:45 -0000
@@ -178,7 +178,7 @@
}
-/* Return a string descibing the type and kind of a typespec. Because
+/* Return a string describing the type and kind of a typespec. Because
we return alternating buffers, this subroutine can appear twice in
the argument list of a single statement. */
@@ -245,8 +245,8 @@
}
-/* Given an mstring array and a string, returns the value of the tag
- field. Returns the final tag if no matches to the string are
+/* Given an mstring array and a string, return the value of the tag
+ field. Return the final tag if no matches to the string are
found. */
int
Index: options.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/Attic/options.c,v
retrieving revision 1.1.2.11
diff -u -u -r1.1.2.11 options.c
--- options.c 4 Apr 2004 15:33:41 -0000 1.1.2.11
+++ options.c 4 Apr 2004 21:51:46 -0000
@@ -56,6 +56,7 @@
gfc_option.warn_implicit_interface = 0;
gfc_option.warn_line_truncation = 0;
gfc_option.warn_surprising = 0;
+ gfc_option.warn_underflow = 0;
gfc_option.warn_unused_labels = 0;
gfc_option.flag_dollar_ok = 0;
@@ -123,6 +124,7 @@
gfc_option.warn_aliasing = 1;
gfc_option.warn_line_truncation = 1;
gfc_option.warn_surprising = 1;
+ gfc_option.warn_underflow = 1;
gfc_option.warn_unused_labels = 1;
set_Wunused (1);
@@ -199,6 +201,10 @@
case OPT_Wsurprising:
gfc_option.warn_surprising = value;
+ break;
+
+ case OPT_Wunderflow:
+ gfc_option.warn_underflow = value;
break;
case OPT_Wunused_labels:
More information about the Fortran
mailing list