public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "kargl at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/96911] bug with Intrinsic shifta/shiftl/shiftr
Date: Thu, 03 Sep 2020 16:44:30 +0000	[thread overview]
Message-ID: <bug-96911-4-WN4Otg9I6z@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-96911-4@http.gcc.gnu.org/bugzilla/>

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

  parent reply	other threads:[~2020-09-03 16:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-03  7:28 [Bug fortran/96911] New: " 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 [this message]
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

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=bug-96911-4-WN4Otg9I6z@http.gcc.gnu.org/bugzilla/ \
    --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).