public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/96911] New: bug with Intrinsic shifta/shiftl/shiftr
@ 2020-09-03  7:28 zhen.xu@compiler-dev.com
  2020-09-03 14:44 ` [Bug fortran/96911] " anlauf at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: zhen.xu@compiler-dev.com @ 2020-09-03  7:28 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96911
           Summary: bug with Intrinsic shifta/shiftl/shiftr
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhen.xu@compiler-dev.com
  Target Milestone: ---

Dealing with Intrinsic shifta/shiftl/shiftr, gfortran refuses proper numbers in
the code below and throws "Error: Integer too big for its kind". 

The code is checked with ifort.

-------code----------
program test
  print *, shifta(-128_1, 1);
  print *, shifta(-32768_2, 1);
  print *, shifta(-2147483648_4, 1);
  print *, shifta(-9223372036854775808_8, 1);

  print *, shiftl(-128_1, 1);
  print *, shiftl(-32768_2, 1);
  print *, shiftl(-2147483648_4, 1);
  print *, shiftl(-9223372036854775808_8, 1);

  print *, shiftr(-128_1, 1);
  print *, shiftr(-32768_2, 1);
  print *, shiftr(-2147483648_4, 1);
  print *, shiftr(-9223372036854775808_8, 1);

end
----------------------

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

* [Bug fortran/96911] bug with Intrinsic shifta/shiftl/shiftr
  2020-09-03  7:28 [Bug fortran/96911] New: bug with Intrinsic shifta/shiftl/shiftr zhen.xu@compiler-dev.com
@ 2020-09-03 14:44 ` anlauf at gcc dot gnu.org
  2020-09-03 16:44 ` kargl at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: anlauf at gcc dot gnu.org @ 2020-09-03 14:44 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |anlauf at gcc dot gnu.org

--- Comment #1 from anlauf at gcc dot gnu.org ---
Error: Integer too big for its kind at (1). This check can be disabled with the
option '-fno-range-check'

Why don't you read what gfortran is telling you, and acting appropriately?

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

* [Bug fortran/96911] bug with Intrinsic shifta/shiftl/shiftr
  2020-09-03  7:28 [Bug fortran/96911] New: bug with Intrinsic shifta/shiftl/shiftr zhen.xu@compiler-dev.com
  2020-09-03 14:44 ` [Bug fortran/96911] " anlauf at gcc dot gnu.org
@ 2020-09-03 16:44 ` kargl at gcc dot gnu.org
  2020-09-04  0:54 ` zhen.xu@compiler-dev.com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: kargl at gcc dot gnu.org @ 2020-09-03 16:44 UTC (permalink / raw)
  To: gcc-bugs

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

kargl at gcc dot gnu.org changed:

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

--- Comment #2 from kargl at gcc dot gnu.org ---
(In reply to zhen.xu from comment #0)
> Dealing with Intrinsic shifta/shiftl/shiftr, gfortran refuses proper numbers
> in the code below and throws "Error: Integer too big for its kind". 
> 
> The code is checked with ifort.
> 
> -------code----------
> program test
>   print *, shifta(-128_1, 1);
>   print *, shifta(-32768_2, 1);
>   print *, shifta(-2147483648_4, 1);
>   print *, shifta(-9223372036854775808_8, 1);
> 
>   print *, shiftl(-128_1, 1);
>   print *, shiftl(-32768_2, 1);
>   print *, shiftl(-2147483648_4, 1);
>   print *, shiftl(-9223372036854775808_8, 1);
> 
>   print *, shiftr(-128_1, 1);
>   print *, shiftr(-32768_2, 1);
>   print *, shiftr(-2147483648_4, 1);
>   print *, shiftr(-9223372036854775808_8, 1);
> 
> end
> ----------------------

There are no negative integer withs gfortran.  -128_1 is a unary minus
operator and 128_1 is a invalid operand. 128_1 would be greater than
huge(1_1).  The only way to get the most "negative integer" is
to do -huge(1_1) - 1 (assuming twos-complement arithmetic applies).

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

* [Bug fortran/96911] bug with Intrinsic shifta/shiftl/shiftr
  2020-09-03  7:28 [Bug fortran/96911] New: bug with Intrinsic shifta/shiftl/shiftr zhen.xu@compiler-dev.com
  2020-09-03 14:44 ` [Bug fortran/96911] " anlauf at gcc dot gnu.org
  2020-09-03 16:44 ` kargl at gcc dot gnu.org
@ 2020-09-04  0:54 ` zhen.xu@compiler-dev.com
  2020-09-04  1:03 ` zhen.xu@compiler-dev.com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: zhen.xu@compiler-dev.com @ 2020-09-04  0:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from zhen.xu@compiler-dev.com ---
(In reply to anlauf from comment #1)
> Error: Integer too big for its kind at (1). This check can be disabled with
> the option '-fno-range-check'
> 
> Why don't you read what gfortran is telling you, and acting appropriately?


The fact is -128 is surely not too big for integer(1). The below code is
compiled by gfortran and can print out -128 properly.
--------------------
program testint
      integer(1) :: x = -128
      print *, x
end
____________________

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

* [Bug fortran/96911] bug with Intrinsic shifta/shiftl/shiftr
  2020-09-03  7:28 [Bug fortran/96911] New: bug with Intrinsic shifta/shiftl/shiftr zhen.xu@compiler-dev.com
                   ` (2 preceding siblings ...)
  2020-09-04  0:54 ` zhen.xu@compiler-dev.com
@ 2020-09-04  1:03 ` zhen.xu@compiler-dev.com
  2020-09-04  1:18 ` zhen.xu@compiler-dev.com
  2020-09-04  1:20 ` zhen.xu@compiler-dev.com
  5 siblings, 0 replies; 7+ messages in thread
From: zhen.xu@compiler-dev.com @ 2020-09-04  1:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from zhen.xu@compiler-dev.com ---
(In reply to kargl from comment #2)
> (In reply to zhen.xu from comment #0)
> > Dealing with Intrinsic shifta/shiftl/shiftr, gfortran refuses proper numbers
> > in the code below and throws "Error: Integer too big for its kind". 
> > 
> > The code is checked with ifort.
> > 
> > -------code----------
> > program test
> >   print *, shifta(-128_1, 1);
> >   print *, shifta(-32768_2, 1);
> >   print *, shifta(-2147483648_4, 1);
> >   print *, shifta(-9223372036854775808_8, 1);
> > 
> >   print *, shiftl(-128_1, 1);
> >   print *, shiftl(-32768_2, 1);
> >   print *, shiftl(-2147483648_4, 1);
> >   print *, shiftl(-9223372036854775808_8, 1);
> > 
> >   print *, shiftr(-128_1, 1);
> >   print *, shiftr(-32768_2, 1);
> >   print *, shiftr(-2147483648_4, 1);
> >   print *, shiftr(-9223372036854775808_8, 1);
> > 
> > end
> > ----------------------
> 
> There are no negative integer withs gfortran.  -128_1 is a unary minus
> operator and 128_1 is a invalid operand. 128_1 would be greater than
> huge(1_1).  The only way to get the most "negative integer" is
> to do -huge(1_1) - 1 (assuming twos-complement arithmetic applies).

But how can the code below be compiled by gfortran well and print out -128
properly?
--------------------
program testint
      integer(1) :: x = -128
      print *, x
end
____________________

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

* [Bug fortran/96911] bug with Intrinsic shifta/shiftl/shiftr
  2020-09-03  7:28 [Bug fortran/96911] New: bug with Intrinsic shifta/shiftl/shiftr zhen.xu@compiler-dev.com
                   ` (3 preceding siblings ...)
  2020-09-04  1:03 ` zhen.xu@compiler-dev.com
@ 2020-09-04  1:18 ` zhen.xu@compiler-dev.com
  2020-09-04  1:20 ` zhen.xu@compiler-dev.com
  5 siblings, 0 replies; 7+ messages in thread
From: zhen.xu@compiler-dev.com @ 2020-09-04  1:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from zhen.xu@compiler-dev.com ---
(In reply to kargl from comment #2)
> (In reply to zhen.xu from comment #0)
> > Dealing with Intrinsic shifta/shiftl/shiftr, gfortran refuses proper numbers
> > in the code below and throws "Error: Integer too big for its kind". 
> > 
> > The code is checked with ifort.
> > 
> > -------code----------
> > program test
> >   print *, shifta(-128_1, 1);
> >   print *, shifta(-32768_2, 1);
> >   print *, shifta(-2147483648_4, 1);
> >   print *, shifta(-9223372036854775808_8, 1);
> > 
> >   print *, shiftl(-128_1, 1);
> >   print *, shiftl(-32768_2, 1);
> >   print *, shiftl(-2147483648_4, 1);
> >   print *, shiftl(-9223372036854775808_8, 1);
> > 
> >   print *, shiftr(-128_1, 1);
> >   print *, shiftr(-32768_2, 1);
> >   print *, shiftr(-2147483648_4, 1);
> >   print *, shiftr(-9223372036854775808_8, 1);
> > 
> > end
> > ----------------------
> 
> There are no negative integer withs gfortran.  -128_1 is a unary minus
> operator and 128_1 is a invalid operand. 128_1 would be greater than
> huge(1_1).  The only way to get the most "negative integer" is
> to do -huge(1_1) - 1 (assuming twos-complement arithmetic applie
You are right(In reply to anlauf from comment #1)
> Error: Integer too big for its kind at (1). This check can be disabled with
> the option '-fno-range-check'
> 
> Why don't you read what gfortran is telling you, and acting appropriately?

Sorry, I made a mistake. You are right.
(In reply to anlauf from comment #1)
> Error: Integer too big for its kind at (1). This check can be disabled with
> the option '-fno-range-check'
> 
> Why don't you read what gfortran is telling you, and acting appropriately?

You are right! I made a mistake, please ignore my previous reply.

The right testcase should be below and it throws out the same prompt.
-------------------------------
program testint
  integer(1) :: x = -128_1
  print *, x
end
-------------------------------

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

* [Bug fortran/96911] bug with Intrinsic shifta/shiftl/shiftr
  2020-09-03  7:28 [Bug fortran/96911] New: bug with Intrinsic shifta/shiftl/shiftr zhen.xu@compiler-dev.com
                   ` (4 preceding siblings ...)
  2020-09-04  1:18 ` zhen.xu@compiler-dev.com
@ 2020-09-04  1:20 ` zhen.xu@compiler-dev.com
  5 siblings, 0 replies; 7+ messages in thread
From: zhen.xu@compiler-dev.com @ 2020-09-04  1:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from zhen.xu@compiler-dev.com ---
(In reply to kargl from comment #2)
> (In reply to zhen.xu from comment #0)
> > Dealing with Intrinsic shifta/shiftl/shiftr, gfortran refuses proper numbers
> > in the code below and throws "Error: Integer too big for its kind". 
> > 
> > The code is checked with ifort.
> > 
> > -------code----------
> > program test
> >   print *, shifta(-128_1, 1);
> >   print *, shifta(-32768_2, 1);
> >   print *, shifta(-2147483648_4, 1);
> >   print *, shifta(-9223372036854775808_8, 1);
> > 
> >   print *, shiftl(-128_1, 1);
> >   print *, shiftl(-32768_2, 1);
> >   print *, shiftl(-2147483648_4, 1);
> >   print *, shiftl(-9223372036854775808_8, 1);
> > 
> >   print *, shiftr(-128_1, 1);
> >   print *, shiftr(-32768_2, 1);
> >   print *, shiftr(-2147483648_4, 1);
> >   print *, shiftr(-9223372036854775808_8, 1);
> > 
> > end
> > ----------------------
> 
> There are no negative integer withs gfortran.  -128_1 is a unary minus
> operator and 128_1 is a invalid operand. 128_1 would be greater than
> huge(1_1).  The only way to get the most "negative integer" is
> to do -huge(1_1) - 1 (assuming twos-complement arithmetic applies).

You are right! I made a mistake, please ignore my previous reply.

The right testcase should be below and it throws out the same prompt.
-------------------------------
program testint
  integer(1) :: x = -128_1
  print *, x
end
-------------------------------

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

end of thread, other threads:[~2020-09-04  1:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-03  7:28 [Bug fortran/96911] New: bug with Intrinsic shifta/shiftl/shiftr zhen.xu@compiler-dev.com
2020-09-03 14:44 ` [Bug fortran/96911] " anlauf at gcc dot gnu.org
2020-09-03 16:44 ` kargl at gcc dot gnu.org
2020-09-04  0:54 ` zhen.xu@compiler-dev.com
2020-09-04  1:03 ` zhen.xu@compiler-dev.com
2020-09-04  1:18 ` zhen.xu@compiler-dev.com
2020-09-04  1:20 ` zhen.xu@compiler-dev.com

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