public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "sgk at troutmask dot apl dot washington dot edu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/30512] MAXVAL() incorrect for zero-size int arrays, and for -HUGE-1 maximum values.
Date: Mon, 22 Jan 2007 20:16:00 -0000 [thread overview]
Message-ID: <20070122201617.5024.qmail@sourceware.org> (raw)
In-Reply-To: <bug-30512-13350@http.gcc.gnu.org/bugzilla/>
------- Comment #5 from sgk at troutmask dot apl dot washington dot edu 2007-01-22 20:16 -------
Subject: Re: MAXVAL() incorrect for zero-size int arrays, and for -HUGE-1
maximum values.
>
>- Comment #3 from fxcoudert at gcc dot gnu dot org 2007-01-22 07:56 -------
> I don't think it's a bug, since "the negative number with the largest
> magnitude possible within the representation" is not -huge()-1, but -huge().
>
> If I understand the standard correctly, -huge()-1, although being
> representible by the hardware you have, is not "within the representation"
> of this integer kind, because the range of the representation of an
> integer kind is supposed to be symmetric.
>
> For what it's worth, the Intel and Sun compilers have the behaviour
> you expect, but the Portland compiler and g95 both have the same
> behaviour as gfortran.
>
> Steve might have an idea on that, IIRC he's the one who implemented the
> -frange-check option. Otherwise, a question to comp.lang.fortran would be a
> good thing.
>
I fixed the range checking from [-huge()-1: 2*huge()] to
[-huge()-1: huge()]. The old upper limited would allow
people to write
integer(1) i
i = -128_1 ! This should be -huge(i) - 1_1
end
because the 128_1 was not flagged as overflowing a integer(1).
Note, -128_1 is a unary minus operating on the 128_1.
When I changed the range checking or shortly after, jerryd
introduced the -f[no]-range-check option.
For the case at hand, the integers do not need to be symmetric,
and so minval and maxval should properly handle -huge()-1. As
pointed out by Tobias,
integer(1) a(2)
a = -huge(a) - 1
print *, minval(a), maxval(a)
end
should print "-128 -128"
Now, where the symmetry of the integers becomes a problem is
integer(1) i
i = - huge() - 1
i = abs(i) ! This is invalid.
end
The above is prohibited in 13.14:
The types and type parameters of intrinsic procedure arguments
and function results are determined by these specifications. A
program is prohibited from invoking an intrinsic procedure
under circumstances where a value to be returned in a subroutine
argument or function result is outside the range of values
representable by objects of the specified type and type parameters.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30512
next prev parent reply other threads:[~2007-01-22 20:16 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-20 0:10 [Bug fortran/30512] New: " brooks at gcc dot gnu dot org
2007-01-20 9:38 ` [Bug fortran/30512] " burnus at gcc dot gnu dot org
2007-01-20 12:46 ` burnus at gcc dot gnu dot org
2007-01-22 7:56 ` fxcoudert at gcc dot gnu dot org
2007-01-22 8:47 ` burnus at gcc dot gnu dot org
2007-01-22 20:16 ` sgk at troutmask dot apl dot washington dot edu [this message]
2007-01-27 13:24 ` tkoenig at gcc dot gnu dot org
2007-01-28 22:39 ` tkoenig at gcc dot gnu dot org
2007-01-29 8:40 ` burnus at gcc dot gnu dot org
2007-01-30 17:58 ` burnus at gcc dot gnu dot org
2007-02-01 9:01 ` patchapp at dberlin dot org
2007-02-09 21:56 ` burnus at gcc dot gnu dot org
2007-02-16 14:16 ` [Bug fortran/30512] [4.2, 4.1 only] " burnus at gcc dot gnu dot org
2007-02-16 14:17 ` [Bug fortran/30512] [4.1 " burnus at gcc dot gnu dot org
2007-02-17 21:29 ` tkoenig at gcc dot gnu dot org
2007-02-20 17:39 ` burnus at gcc dot gnu dot org
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070122201617.5024.qmail@sourceware.org \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).