public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/43310] -pedantic errors involving PARAMETERs and out of range result
       [not found] <bug-43310-4@http.gcc.gnu.org/bugzilla/>
@ 2010-11-03 17:34 ` kargl at gcc dot gnu.org
  2013-07-01 20:41 ` dominiq at lps dot ens.fr
  2015-10-10  8:39 ` dominiq at lps dot ens.fr
  2 siblings, 0 replies; 9+ messages in thread
From: kargl at gcc dot gnu.org @ 2010-11-03 17:34 UTC (permalink / raw)
  To: gcc-bugs

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

kargl at gcc dot gnu.org changed:

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

--- Comment #14 from kargl at gcc dot gnu.org 2010-11-03 17:33:59 UTC ---
(In reply to comment #13)
> (In reply to comment #11)
> > > Well, the number model is symmetric. See Fortran 2003 ...
> > 
> > I agree, but it is a very pedantic view that should at least be mentioned in
> > the manual.
> 
> You forgot to attach your patch.
> 
> > Now I think the implementation is not consistent:
> > 
> > [macbook] f90/bug% cat > ishft_1.f90
> > print *, ishft(1,31)
> > end
> > [macbook] f90/bug% gfc -Wall -pedantic ishft_1.f90
> > [macbook] f90/bug% a.out
> >  -2147483648
> 
> gfc_simplify_ishft doesn't range check its result.
> Patch welcomed.

laptop:kargl[210] gfc4x -o z t.f90
laptop:kargl[211] ./z
 -2147483648
laptop:kargl[212] gfc4x -o z -pedantic t.f90
t.f90:1.14:

print*, ishft(1,31)
              1
Error: Result of ISHFT gives range error for its kind at (1)

Index: simplify.c
===================================================================
--- simplify.c  (revision 166091)
+++ simplify.c  (working copy)
@@ -3002,7 +3002,7 @@ simplify_shift (gfc_expr *e, gfc_expr *s
   convert_mpz_to_signed (result->value.integer, bitsize);
   gfc_free (bits);

-  return result;
+  return  range_check (result, name);
 }


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

* [Bug fortran/43310] -pedantic errors involving PARAMETERs and out of range result
       [not found] <bug-43310-4@http.gcc.gnu.org/bugzilla/>
  2010-11-03 17:34 ` [Bug fortran/43310] -pedantic errors involving PARAMETERs and out of range result kargl at gcc dot gnu.org
@ 2013-07-01 20:41 ` dominiq at lps dot ens.fr
  2015-10-10  8:39 ` dominiq at lps dot ens.fr
  2 siblings, 0 replies; 9+ messages in thread
From: dominiq at lps dot ens.fr @ 2013-07-01 20:41 UTC (permalink / raw)
  To: gcc-bugs

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

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2013-07-01

--- Comment #15 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
What should be done with this two and a half year old PR?
Apply the patch in comment #14 or closing it as INVALID or WONTFIX?


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

* [Bug fortran/43310] -pedantic errors involving PARAMETERs and out of range result
       [not found] <bug-43310-4@http.gcc.gnu.org/bugzilla/>
  2010-11-03 17:34 ` [Bug fortran/43310] -pedantic errors involving PARAMETERs and out of range result kargl at gcc dot gnu.org
  2013-07-01 20:41 ` dominiq at lps dot ens.fr
@ 2015-10-10  8:39 ` dominiq at lps dot ens.fr
  2 siblings, 0 replies; 9+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-10-10  8:39 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43310

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|---                         |WONTFIX

--- Comment #16 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> What should be done with this two and a half year old PR?
> Apply the patch in comment #14 or closing it as INVALID or WONTFIX?

After more than two years without feedback closing as WONTFIX.


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

* [Bug fortran/43310] -pedantic errors involving PARAMETERs and out of range result
  2010-03-09 19:06 [Bug fortran/43310] New: -pedantic errors on valid code involving PARAMETERs initialized to intrinsic function result giese025 at umn dot edu
                   ` (4 preceding siblings ...)
  2010-03-17 22:20 ` kargl at gcc dot gnu dot org
@ 2010-03-17 22:27 ` kargl at gcc dot gnu dot org
  5 siblings, 0 replies; 9+ messages in thread
From: kargl at gcc dot gnu dot org @ 2010-03-17 22:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #13 from kargl at gcc dot gnu dot org  2010-03-17 22:26 -------
(In reply to comment #11)
> > Well, the number model is symmetric. See Fortran 2003 ...
> 
> I agree, but it is a very pedantic view that should at least be mentioned in
> the manual.

You forgot to attach your patch.

> Now I think the implementation is not consistent:
> 
> [macbook] f90/bug% cat > ishft_1.f90
> print *, ishft(1,31)
> end
> [macbook] f90/bug% gfc -Wall -pedantic ishft_1.f90
> [macbook] f90/bug% a.out
>  -2147483648

gfc_simplify_ishft doesn't range check its result.
Patch welcomed.


-- 


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


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

* [Bug fortran/43310] -pedantic errors involving PARAMETERs and out of range result
  2010-03-09 19:06 [Bug fortran/43310] New: -pedantic errors on valid code involving PARAMETERs initialized to intrinsic function result giese025 at umn dot edu
                   ` (3 preceding siblings ...)
  2010-03-17 21:31 ` dominiq at lps dot ens dot fr
@ 2010-03-17 22:20 ` kargl at gcc dot gnu dot org
  2010-03-17 22:27 ` kargl at gcc dot gnu dot org
  5 siblings, 0 replies; 9+ messages in thread
From: kargl at gcc dot gnu dot org @ 2010-03-17 22:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from kargl at gcc dot gnu dot org  2010-03-17 22:20 -------
(In reply to comment #10)
> (In reply to comment #9)
> > (In reply to comment #8)
> > > Maybe we just need to document that -pedantic changes the range of integers to
> > > be what the Fortran standard requires (a symmetric range).
> > 
> > The Fortran Standard requires neither a symmetric nor asymmetric
> > range.
> 
> Well, the number model is symmetric. 

You're preaching to the choir. ;)

Yes, the model number representation of integer is symmetric.
However, the representable range on integer does not have to
correspond to the model numbers.

function myabs(i)
  myabs = iabs(i)
end function myabs

function mynot(i)
  mynot = not(i)
end function mynot

Do these functions conform to the standard for all poosible
values of i? Careful with your answer.


-- 


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


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

* [Bug fortran/43310] -pedantic errors involving PARAMETERs and out of range result
  2010-03-09 19:06 [Bug fortran/43310] New: -pedantic errors on valid code involving PARAMETERs initialized to intrinsic function result giese025 at umn dot edu
                   ` (2 preceding siblings ...)
  2010-03-17 20:16 ` burnus at gcc dot gnu dot org
@ 2010-03-17 21:31 ` dominiq at lps dot ens dot fr
  2010-03-17 22:20 ` kargl at gcc dot gnu dot org
  2010-03-17 22:27 ` kargl at gcc dot gnu dot org
  5 siblings, 0 replies; 9+ messages in thread
From: dominiq at lps dot ens dot fr @ 2010-03-17 21:31 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from dominiq at lps dot ens dot fr  2010-03-17 21:31 -------
> Well, the number model is symmetric. See Fortran 2003 ...

I agree, but it is a very pedantic view that should at least be mentioned in
the manual. 
Now I think the implementation is not consistent:

[macbook] f90/bug% cat > ishft_1.f90
print *, ishft(1,31)
end
[macbook] f90/bug% gfc -Wall -pedantic ishft_1.f90
[macbook] f90/bug% a.out
 -2147483648


-- 


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


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

* [Bug fortran/43310] -pedantic errors involving PARAMETERs and out of range result
  2010-03-09 19:06 [Bug fortran/43310] New: -pedantic errors on valid code involving PARAMETERs initialized to intrinsic function result giese025 at umn dot edu
  2010-03-13  1:18 ` [Bug fortran/43310] -pedantic errors involving PARAMETERs and out of range result pinskia at gcc dot gnu dot org
  2010-03-13  3:52 ` kargl at gcc dot gnu dot org
@ 2010-03-17 20:16 ` burnus at gcc dot gnu dot org
  2010-03-17 21:31 ` dominiq at lps dot ens dot fr
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-03-17 20:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from burnus at gcc dot gnu dot org  2010-03-17 20:16 -------
(In reply to comment #9)
> (In reply to comment #8)
> > Maybe we just need to document that -pedantic changes the range of integers to
> > be what the Fortran standard requires (a symmetric range).
> 
> The Fortran Standard requires neither a symmetric nor asymmetric
> range.

Well, the number model is symmetric. See Fortran 2003
(http://www.j3-fortran.org/doc/year/04/04-007.pdf):

"13.4 Numeric models" [...]
"The model set for integer i is defined by

  i = s * sum_{k=0}^{q-1} w_k * r^k

where r is an integer exceeding one, q is a positive integer, each wk is a
nonnegative integer less than r, and s is +1 or &#8722;1."

> It simply requires that a program(mer) cannot invoke an
> intrinsic procedure that will return an out-of-range value.

That can be found in "13.7 Specifications of the standard intrinsic
procedures":

"A program is prohibited from invoking an intrinsic procedure under cir10
cumstances 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, unless the intrinsic module IEEE ARITHMETIC (section
14) is accessible and there is support for an infinite or a NaN result, as
appropriate."


-- 


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


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

* [Bug fortran/43310] -pedantic errors involving PARAMETERs and out of range result
  2010-03-09 19:06 [Bug fortran/43310] New: -pedantic errors on valid code involving PARAMETERs initialized to intrinsic function result giese025 at umn dot edu
  2010-03-13  1:18 ` [Bug fortran/43310] -pedantic errors involving PARAMETERs and out of range result pinskia at gcc dot gnu dot org
@ 2010-03-13  3:52 ` kargl at gcc dot gnu dot org
  2010-03-17 20:16 ` burnus at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: kargl at gcc dot gnu dot org @ 2010-03-13  3:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from kargl at gcc dot gnu dot org  2010-03-13 03:52 -------
(In reply to comment #8)
> Maybe we just need to document that -pedantic changes the range of integers to
> be what the Fortran standard requires (a symmetric range).

The Fortran Standard requires neither a symmetric nor asymmetric
range.  It simply requires that a program(mer) cannot invoke an
intrinsic procedure that will return an out-of-range value.

program one
  integer i
  i = not(1)
end program one

is a valid Fortran 95 program if INTEGER has the range [-huge()-1:huge()]
(assuming a twos complement system). If the range is, however,
[-huge():huge()], then it is an invalid program.  Guess what happen
when the stupid option -pedantic is used?  It changes the range, and this
behavior is completely conforming.


-- 


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


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

* [Bug fortran/43310] -pedantic errors involving PARAMETERs and out of range result
  2010-03-09 19:06 [Bug fortran/43310] New: -pedantic errors on valid code involving PARAMETERs initialized to intrinsic function result giese025 at umn dot edu
@ 2010-03-13  1:18 ` pinskia at gcc dot gnu dot org
  2010-03-13  3:52 ` kargl at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2010-03-13  1:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from pinskia at gcc dot gnu dot org  2010-03-13 01:18 -------
Maybe we just need to document that -pedantic changes the range of integers to
be what the Fortran standard requires (a symmetric range).

> Not all valid FORTRAN 95 programs will compile properly when using this
> option. 

Except it is not a valid Fortran 95 program as the standard requires the ranges
to be symmetric.  (note to be picky only the F is uppercase for Fortran 95; the
last one which was all upper case was 77).


-- 


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


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

end of thread, other threads:[~2015-10-10  8:39 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-43310-4@http.gcc.gnu.org/bugzilla/>
2010-11-03 17:34 ` [Bug fortran/43310] -pedantic errors involving PARAMETERs and out of range result kargl at gcc dot gnu.org
2013-07-01 20:41 ` dominiq at lps dot ens.fr
2015-10-10  8:39 ` dominiq at lps dot ens.fr
2010-03-09 19:06 [Bug fortran/43310] New: -pedantic errors on valid code involving PARAMETERs initialized to intrinsic function result giese025 at umn dot edu
2010-03-13  1:18 ` [Bug fortran/43310] -pedantic errors involving PARAMETERs and out of range result pinskia at gcc dot gnu dot org
2010-03-13  3:52 ` kargl at gcc dot gnu dot org
2010-03-17 20:16 ` burnus at gcc dot gnu dot org
2010-03-17 21:31 ` dominiq at lps dot ens dot fr
2010-03-17 22:20 ` kargl at gcc dot gnu dot org
2010-03-17 22:27 ` kargl at gcc dot gnu dot org

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