public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/94809] New: Different results between gcc-9 and gcc-6
@ 2020-04-27 20:54 k.even-mendoza at imperial dot ac.uk
  2020-04-27 21:03 ` [Bug c/94809] [8/9/10 Regression] " redi at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: k.even-mendoza at imperial dot ac.uk @ 2020-04-27 20:54 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 94809
           Summary: Different results between gcc-9 and gcc-6
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: k.even-mendoza at imperial dot ac.uk
  Target Milestone: ---

Seen on: 18.04.4 LTS
kar@kar-VirtualBox:~/ex1$ gcc-9 ex2.c -o ex
kar@kar-VirtualBox:~/ex1$ ./ex
0
kar@kar-VirtualBox:~/ex1$ gcc-6 ex2.c -o ex
kar@kar-VirtualBox:~/ex1$ ./ex
1
kar@kar-VirtualBox:~/ex1$ more ex2.c 
#include <stdio.h>

int main() {
   int a = 0;
   unsigned long long one = 1;
   ((18446744073709551615UL / one) < a++, one);

   printf("%d\n", a);
}
===
1. Output shall be 1 instead of 0.
2. GCC-7, GCC-8, GCC-9 and HEAD 562bfb1 produce 0.
        gcc-9 (Ubuntu 9.2.1-17ubuntu1~18.04.1) 9.2.1 20191102
        gcc-8 (Ubuntu 8.4.0-1ubuntu1~18.04) 8.4.0
        gcc-7 (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
        gcc-6 (Ubuntu 6.5.0-2ubuntu1~18.04) 6.5.0 20181026
        compiled: gcc-9 ex2.c -o ex
3. Explanation:
((18446744073709551615UL / one) < a++, one); the part before "," is skipped
including the increase of "a" by "1" (a++). As a result the printf outputs 0
instead of 1.
4. GCC-6 and LLVM (for example) produce 1. Note: You can try to compile the
code with GCC-6 or llvm to observe the behaviour where the output is 1.

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

end of thread, other threads:[~2022-03-19  4:16 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-27 20:54 [Bug c/94809] New: Different results between gcc-9 and gcc-6 k.even-mendoza at imperial dot ac.uk
2020-04-27 21:03 ` [Bug c/94809] [8/9/10 Regression] " redi at gcc dot gnu.org
2020-04-27 21:03 ` redi at gcc dot gnu.org
2020-04-27 21:06 ` redi at gcc dot gnu.org
2020-04-27 22:24 ` jakub at gcc dot gnu.org
2020-04-27 22:31 ` [Bug tree-optimization/94809] " jakub at gcc dot gnu.org
2020-04-28  7:50 ` rguenth at gcc dot gnu.org
2020-04-28  7:50 ` rguenth at gcc dot gnu.org
2020-04-28  9:28 ` cvs-commit at gcc dot gnu.org
2020-04-28  9:29 ` [Bug tree-optimization/94809] [8/9 " jakub at gcc dot gnu.org
2020-09-16 19:21 ` cvs-commit at gcc dot gnu.org
2020-09-17 17:38 ` jakub at gcc dot gnu.org
2022-03-19  4:16 ` pinskia 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).