public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "bradley_bell at yahoo dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/98151] New: integer output gives different results with -O2 and -O3
Date: Sat, 05 Dec 2020 03:11:33 +0000	[thread overview]
Message-ID: <bug-98151-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 98151
           Summary: integer output gives different results with -O2 and
                    -O3
           Product: gcc
           Version: 10.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bradley_bell at yahoo dot com
  Target Milestone: ---

Created attachment 49688
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49688&action=edit
bash shell script that creates the souce code, compiles, and runs the test

The attached bash script creates a c++ file called int_output.cpp, then
compiles and runs the program. If you run the script with no arguments you will
get the following usage message:

    usage: ./int_output.sh print optimize
    print:    is either 0 or 1
    optimize: is -O2 or -O3

    If print is 0 and optimize is -O3, the test will fail.
    Otherwise, the test will pass

The program starts with the maximum integer, uses a stringstream to convert it
to a string, and then converts it back to an integer. It then checks that the
result is the maximum integer; i.e., the integer it started with.

If print is 0 (1) the value of the starting and ending integers are printed.
The optimize argument determines the optimization level during the g++
compliation.

The only case that fails is when print is 0 and optimize is -O3.
In addition, if one uses clang++, instead of g++, all the cases give the
correct result.

             reply	other threads:[~2020-12-05  3:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-05  3:11 bradley_bell at yahoo dot com [this message]
2020-12-05  3:18 ` [Bug c++/98151] " pinskia at gcc dot gnu.org
2020-12-05  4:07 ` bradley_bell at yahoo dot com
2020-12-05  9:21 ` jakub at gcc dot gnu.org
2020-12-05 13:56 ` redi at gcc dot gnu.org
2020-12-05 14:50 ` bradley_bell at yahoo dot 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-98151-4@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).