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] PR 52428 Reading of large negative values and range checking


PING

On Thu, Apr 26, 2012 at 12:08 AM, Janne Blomqvist
<blomqvist.janne@gmail.com> wrote:
> Hi,
>
> currently when -frange-check is enabled, we check for overflow when
> doing a formatted read of an integer value. This check, however, is
> against the Fortran numerical model (see 13.4 in F2008), which defines
> a symmetric interval [-huge(), huge()], whereas all targets gfortran
> supports use a two's complement representation with a range of
> [-huge()-1, huge()].
>
> However, there is no checking against the numerical model when doing
> arithmetic, and thus we can generate and write the value -huge()-1,
> but we cannot read it back in! With the -fno-range-check option, this
> overflow checking can be disabled, but at the cost of disabling all
> overflow checking, which leads to reading nonsense values if the
> hardware supported range overflows.
>
> The attached patch changes this logic such that overflow checking
> against the hardware supported range [-huge()-1, huge()] is always
> done when reading, regardless of the -frange-check flag setting. This
> also seems to be what ifort 12.0 does, I haven't checked other
> compilers.
>
> For some more arguments back and forth, see the PR.
>
> Regtested on x86_64-unknown-linux-gnu, Ok for trunk?
>
> gcc/fortran ChangeLog:
>
> 2012-04-25 ÂJanne Blomqvist Â<jb@gcc.gnu.org>
>
> Â Â Â ÂPR fortran/52428
> Â Â Â Â* gfortran.texi: Update _gfortran_set_options documentation.
> Â Â Â Â* invoke.texi: Remove runtime behavior description of
> Â Â Â Â-fno-range-check.
> Â Â Â Â* trans-decl.c (create_main_function): Don't pass the range-check
> Â Â Â Âsetting to the library.
>
>
> libgfortran ChangeLog:
>
> 2012-04-25 ÂJanne Blomqvist Â<jb@gcc.gnu.org>
>
> Â Â Â ÂPR fortran/52428
> Â Â Â Â* io/io.h (max_value): Rename to si_max, remove second argument.
> Â Â Â Â* io/list_read.c (convert_integer): Use unsigned types when
> Â Â Â Âparsing the digits, set max value depending on the sign.
> Â Â Â Â* io/read.c (max_value): Rename to si_max, remove second argument,
> Â Â Â Âsimplify.
> Â Â Â Â(read_decimal): Set max value depending on sign, always check
> Â Â Â Âoverflow.
> Â Â Â Â(read_radix): Calculate max unsigned value directly.
> Â Â Â Â* libgfortran.h (struct compile_options_t): Remove range_check
> Â Â Â Âfield.
> Â Â Â Â* runtime/compile_options.c (set_options): Skip handling
> Â Â Â Âoptions[7].
> Â Â Â Â(init_compile_options): Don't set removed field.
>
>
> gcc/testsuite ChangeLog:
>
> 2012-04-25 ÂJanne Blomqvist Â<jb@gcc.gnu.org>
>
> Â Â Â ÂPR fortran/52428
> Â Â Â Â* gfortran.dg/int_range_io_1.f90: New test.
>
>
> --
> Janne Blomqvist



-- 
Janne Blomqvist


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