public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/98151] New: integer output gives different results with -O2 and -O3
@ 2020-12-05  3:11 bradley_bell at yahoo dot com
  2020-12-05  3:18 ` [Bug c++/98151] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: bradley_bell at yahoo dot com @ 2020-12-05  3:11 UTC (permalink / raw)
  To: gcc-bugs

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.

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

end of thread, other threads:[~2020-12-05 14:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-05  3:11 [Bug c++/98151] New: integer output gives different results with -O2 and -O3 bradley_bell at yahoo dot com
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

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