public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/112550] New: Difference in output from -O0 to -01 ?
@ 2023-11-15 16:48 dcb314 at hotmail dot com
  2023-11-15 16:49 ` [Bug c/112550] " sjames at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: dcb314 at hotmail dot com @ 2023-11-15 16:48 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 112550
           Summary: Difference in output from -O0 to -01 ?
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dcb314 at hotmail dot com
  Target Milestone: ---

Created attachment 56594
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56594&action=edit
C source code

For the attached C code, with this bash script:

$ cat qwe.sh
CC="/home/dcb38/gcc/results/bin/gcc"
FLAGS="-w -ftrivial-auto-var-init=zero -fno-strict-aliasing"

echo bug 981
$CC -O0 $FLAGS bug981.c -o 1.exe
$CC -O1 $FLAGS bug981.c -o 2.exe
./1.exe 1 > 1.out
./2.exe 1 > 2.out
diff 1.out 2.out | head -5

$ source ./qwe.sh
bug 981
38c38
< ...checksum after hashing g_130[i][j] : 19463610
---
> ...checksum after hashing g_130[i][j] : 65FD073B
40c40
$ /home/dcb38/gcc/results/bin/gcc -v 2>&1 | grep exp
gcc version 14.0.0 20231115 (experimental) (081fddbbcf979022) 
$ 

I don't understand why such a trivial change from -O0 to -O1 would cause
such a difference.

Is there perhaps another -f flag I should use to get no difference ?

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

* [Bug c/112550] Difference in output from -O0 to -01 ?
  2023-11-15 16:48 [Bug c/112550] New: Difference in output from -O0 to -01 ? dcb314 at hotmail dot com
@ 2023-11-15 16:49 ` sjames at gcc dot gnu.org
  2023-11-15 16:59 ` dcb314 at hotmail dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: sjames at gcc dot gnu.org @ 2023-11-15 16:49 UTC (permalink / raw)
  To: gcc-bugs

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

Sam James <sjames at gcc dot gnu.org> changed:

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

--- Comment #1 from Sam James <sjames at gcc dot gnu.org> ---
Not sure if I'm misunderstanding you, but it's not trivial to go from -O0 and
-O1 and it's "normal" to have a difference in output in either the case of: a)
UB, or b) a compiler bug (miscompilation).

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

* [Bug c/112550] Difference in output from -O0 to -01 ?
  2023-11-15 16:48 [Bug c/112550] New: Difference in output from -O0 to -01 ? dcb314 at hotmail dot com
  2023-11-15 16:49 ` [Bug c/112550] " sjames at gcc dot gnu.org
@ 2023-11-15 16:59 ` dcb314 at hotmail dot com
  2023-11-15 17:10 ` dcb314 at hotmail dot com
  2023-11-15 22:42 ` xry111 at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: dcb314 at hotmail dot com @ 2023-11-15 16:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from David Binderman <dcb314 at hotmail dot com> ---
(In reply to Sam James from comment #1)
> Not sure if I'm misunderstanding you, but it's not trivial to go from -O0
> and -O1 and it's "normal" to have a difference in output in either the case
> of: a) UB, or b) a compiler bug (miscompilation).

The source code I provided is produced by csmith and then preprocessed.

I tried the upstream unpreprocessed source code on clang -O0 and gcc -O0
and they agreed on the output, so it looked to me like csmith was working ok.

Only when I changed over from gcc -O0 to gcc -O1 did I see a difference.

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

* [Bug c/112550] Difference in output from -O0 to -01 ?
  2023-11-15 16:48 [Bug c/112550] New: Difference in output from -O0 to -01 ? dcb314 at hotmail dot com
  2023-11-15 16:49 ` [Bug c/112550] " sjames at gcc dot gnu.org
  2023-11-15 16:59 ` dcb314 at hotmail dot com
@ 2023-11-15 17:10 ` dcb314 at hotmail dot com
  2023-11-15 22:42 ` xry111 at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: dcb314 at hotmail dot com @ 2023-11-15 17:10 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from David Binderman <dcb314 at hotmail dot com> ---
From a valgrind run:

==4110530== Use of uninitialised value of size 8
==4110530==    at 0x401145: crc32_byte (csmith.h:73)
==4110530==    by 0x401167: crc32_8bytes (csmith.h:99)
==4110530==    by 0x401167: transparent_crc (csmith.h:112)
==4110530==    by 0x401640: main (in.18229.c:890)

I should have thought of valgrind earlier. Sorry.

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

* [Bug c/112550] Difference in output from -O0 to -01 ?
  2023-11-15 16:48 [Bug c/112550] New: Difference in output from -O0 to -01 ? dcb314 at hotmail dot com
                   ` (2 preceding siblings ...)
  2023-11-15 17:10 ` dcb314 at hotmail dot com
@ 2023-11-15 22:42 ` xry111 at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-11-15 22:42 UTC (permalink / raw)
  To: gcc-bugs

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

Xi Ruoyao <xry111 at gcc dot gnu.org> changed:

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

--- Comment #4 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
(In reply to David Binderman from comment #3)
> From a valgrind run:
> 
> ==4110530== Use of uninitialised value of size 8
> ==4110530==    at 0x401145: crc32_byte (csmith.h:73)
> ==4110530==    by 0x401167: crc32_8bytes (csmith.h:99)
> ==4110530==    by 0x401167: transparent_crc (csmith.h:112)
> ==4110530==    by 0x401640: main (in.18229.c:890)
> 
> I should have thought of valgrind earlier. Sorry.

Closing then.

I remember there are already some invalid reports from csmith in this bugzilla.
 Like all other software, csmith is not 100% correct too :).

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

end of thread, other threads:[~2023-11-15 22:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-15 16:48 [Bug c/112550] New: Difference in output from -O0 to -01 ? dcb314 at hotmail dot com
2023-11-15 16:49 ` [Bug c/112550] " sjames at gcc dot gnu.org
2023-11-15 16:59 ` dcb314 at hotmail dot com
2023-11-15 17:10 ` dcb314 at hotmail dot com
2023-11-15 22:42 ` xry111 at gcc dot gnu.org

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