public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/96549] New: Wrong evaluation of a comparison between long & short
@ 2020-08-10  8:03 zhige.yu18 at imperial dot ac.uk
  2020-08-10  8:09 ` [Bug c/96549] [10/11 Regression] " marxin at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: zhige.yu18 at imperial dot ac.uk @ 2020-08-10  8:03 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96549
           Summary: Wrong evaluation of a comparison between long & short
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhige.yu18 at imperial dot ac.uk
  Target Milestone: ---

The following code snippet:


#include <stdio.h>
long c = -1L;
long b = 0L;
int main(void) {
  if (3L > (short) ((c ^= (b = 1L)) * 3L))
    printf("hello ");
  printf("world!\n");
}


> $ /usr/gcc-trunk/bin/gcc -O0 bug.c -o a.out; ./a.out 
> world!
> $ clang-10 -O0 bug.c -o a.out; ./a.out
> hello world!


When compiled with -O0/1/2/3, GCC omits the then-branch of the if-statement,
and prints "world!" only. This bug can be found in GCC-10.2.0 and GCC-11.0.0
20200804 (experimental). GCC-9.3.0 and earlier versions of GCC do not have this
bug.

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

end of thread, other threads:[~2020-08-25 18:23 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-10  8:03 [Bug c/96549] New: Wrong evaluation of a comparison between long & short zhige.yu18 at imperial dot ac.uk
2020-08-10  8:09 ` [Bug c/96549] [10/11 Regression] " marxin at gcc dot gnu.org
2020-08-10  8:20 ` [Bug middle-end/96549] " pinskia at gcc dot gnu.org
2020-08-10  8:20 ` [Bug middle-end/96549] [10/11 Regression] " pinskia at gcc dot gnu.org
2020-08-10  9:10 ` jakub at gcc dot gnu.org
2020-08-10  9:13 ` jakub at gcc dot gnu.org
2020-08-11 11:52 ` cvs-commit at gcc dot gnu.org
2020-08-11 11:53 ` [Bug middle-end/96549] [10 " jakub at gcc dot gnu.org
2020-08-25  8:12 ` rguenth at gcc dot gnu.org
2020-08-25 17:45 ` cvs-commit at gcc dot gnu.org
2020-08-25 18:23 ` jakub 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).