This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] fortran/29147 -- Disable integer range checking.


Steve Kargl wrote:
The -frange-check option is documented in invoke.texi.
Jerry implemented the option to permit Inf and NaN to be computed (e.g., "real :: x = 1. / 0."). During
constant folding, the Inf would trigger an overflow
error.


There is a section in gfortran.texi that describes gfortran-specific extensions involving BOZ constants.
You may want to read this text and perhaps add a blurb
about -fno-range-check.

The attached patch includes the relevant documentation changes in both locations. I've tested it on both PDF and HTML document generation.


- Brooks

(Note that I don't have commit privileges; could the approver please commit this for me?)
Index: gfortran.texi
===================================================================
--- gfortran.texi	(revision 117307)
+++ gfortran.texi	(working copy)
@@ -933,13 +933,20 @@
 @code{INTEGER} variable.  @command{gfortran} permits a BOZ to appear
 in any initialization expression as well as assignment statements.
 
-The use of a BOZ literal constant to initialize a @code{REAL} variable will 
-lead to confusion.  A BOZ literal constant is converted to an
-@code{INTEGER} with the kind type with the largest decimal representation
-before a conversion to a @code{REAL} variable.  That is, one should not
-expect a bitwise copy of the BOZ literal constant to be assigned to the
-@code{REAL}.
+Attempts to use a BOZ literal constant to do a bitwise initialization of a
+variable can lead to confusion.  A BOZ literal constant is converted to an
+@code{INTEGER} value with the kind type with the largest decimal representation,
+and this value is then converted numerically to the type and kind of the
+variable in question.  Thus, one should not expect a bitwise copy of the BOZ
+literal constant to be assigned to a @code{REAL} variable.
 
+Similarly, initializing an @code{INTEGER} variable with a statement such as
+@code{DATA i/Z'FFFFFFFF'/} will produce an integer overflow rather than the
+desired result of @math{-1} when @code{i} is a 32-bit integer on a system that
+supports 64-bit integers.  The @samp{-fno-range-check} option can be used as 
+a workaround for legacy code that initializes integers in this manner.
+
+
 @node Real array indices
 @section Real array indices
 @cindex Real array indices
Index: invoke.texi
===================================================================
--- invoke.texi	(revision 117307)
+++ invoke.texi	(working copy)
@@ -315,7 +315,10 @@
 during compilation.  For example, by default, @command{gfortran} will give
 an overflow error at compile time when simplifying @code{a = EXP(1000)}.
 With @samp{-fno-range-check}, no error will be given and the variable @code{a}
-will be assigned the value @code{+Infinity}.
+will be assigned the value @code{+Infinity}.  Similarly,
+@code{DATA i/Z'FFFFFFFF'/} will result in an integer overflow on most systems,
+but with @samp{-fno-range-check} the value will ``wrap around'' and @code{i}
+will be initialized to @math{-1} instead.
 
 @cindex -std=@var{std} option
 @cindex option, -std=@var{std}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]