public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "sgk at troutmask dot apl.washington.edu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/96859] Wrong answer with intrinsic merge_bits
Date: Tue, 01 Sep 2020 15:54:38 +0000 [thread overview]
Message-ID: <bug-96859-4-5thqB9V2Zq@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-96859-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96859
--- Comment #10 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Tue, Sep 01, 2020 at 03:20:20PM +0000, jakub at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96859
>
> --- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
> I've read that. But I think in this case it is an obvious bug (just, what I've
> missed in the patch, there is another copy of the same bug in another routine).
> The
> /* Clear first bit. */
> if (kind == 1 || kind == 4 || kind == 16)
> {
> if (buf[0] == '4')
> buf[0] = '0';
> else if (buf[0] == '5')
> buf[0] = '1';
> else if (buf[0] == '6')
> buf[0] = '2';
> else if (buf[0] == '7')
> buf[0] = '3';
> }
> part looks correct, for kind 1, 4 and 16 the calculated len times 3 is 1 larger
> than the number of bits it needs, so the above ensures that the first digit is
> 0-3 even if it is 4-7 by subtracting 4.
> But the:
> /* Clear first two bits. */
> else
> {
> if (buf[0] == '4' || buf[0] == '6')
> buf[0] = '0';
> else if (buf[0] == '5' || buf[0] == '7')
> buf[0] = '1';
> }
> which is needed for kind 2 and 8, when he calculated len times 3 is 2 larger
> than the number of bits it needs, is only correct for digits 0-1 an 4-7, for
> which it ensures the digit is 0 if it is even and 1 if it is odd. But 2 and 3
> are kept as is, while they don't fit into 1 bit.
>
It is certainly possible I have/had an off-by-one in handwritten
conversions I was doing; in particular, I don't often work with
octal numbers.
next prev parent reply other threads:[~2020-09-01 15:54 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-31 6:31 [Bug fortran/96859] New: " zhen.xu@compiler-dev.com
2020-08-31 9:53 ` [Bug fortran/96859] " dominiq at lps dot ens.fr
2020-08-31 16:30 ` kargl at gcc dot gnu.org
2020-09-01 12:17 ` zhen.xu@compiler-dev.com
2020-09-01 12:22 ` zhen.xu@compiler-dev.com
2020-09-01 12:52 ` jakub at gcc dot gnu.org
2020-09-01 13:10 ` jakub at gcc dot gnu.org
2020-09-01 13:30 ` jakub at gcc dot gnu.org
2020-09-01 15:02 ` sgk at troutmask dot apl.washington.edu
2020-09-01 15:20 ` jakub at gcc dot gnu.org
2020-09-01 15:54 ` sgk at troutmask dot apl.washington.edu [this message]
2020-09-02 10:19 ` cvs-commit at gcc dot gnu.org
2020-09-11 7:47 ` cvs-commit at gcc dot gnu.org
2021-03-26 18:43 ` anlauf at gcc dot gnu.org
2021-05-31 17:23 ` dominiq at lps dot ens.fr
2021-09-17 6:40 ` pinskia at gcc dot gnu.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=bug-96859-4-5thqB9V2Zq@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).