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

* [Bug c/94809] [8/9/10 Regression] Different results between gcc-9 and gcc-6
  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 ` redi at gcc dot gnu.org
  2020-04-27 21:03 ` redi at gcc dot gnu.org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2020-04-27 21:03 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
      Known to work|                            |6.5.0
     Ever confirmed|0                           |1
      Known to fail|                            |10.0, 7.5.0, 8.4.0, 9.3.0
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2020-04-27
            Summary|Different results between   |[8/9/10 Regression]
                   |gcc-9 and gcc-6             |Different results between
                   |                            |gcc-9 and gcc-6

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

* [Bug c/94809] [8/9/10 Regression] Different results between gcc-9 and gcc-6
  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
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2020-04-27 21:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
With -fsanitize=undefined the result is correct.

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

* [Bug c/94809] [8/9/10 Regression] Different results between gcc-9 and gcc-6
  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
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2020-04-27 21:06 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Regression started with r236882

            PR tree-optimization/71289
            * match.pd (-1 / B < A, A > -1 / B): New transformations.

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

* [Bug c/94809] [8/9/10 Regression] Different results between gcc-9 and gcc-6
  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
                   ` (2 preceding siblings ...)
  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
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-04-27 22:24 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |jakub at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org
   Target Milestone|---                         |8.5

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
That folds it into
IMAGPART_EXPR <.MUL_OVERFLOW ((long long unsigned int) a++ , one)> != 0
which looks correct, but somewhere later the side-effect is dropped.

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

* [Bug tree-optimization/94809] [8/9/10 Regression] Different results between gcc-9 and gcc-6
  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
                   ` (3 preceding siblings ...)
  2020-04-27 22:24 ` jakub at gcc dot gnu.org
@ 2020-04-27 22:31 ` jakub at gcc dot gnu.org
  2020-04-28  7:50 ` rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-04-27 22:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 48390
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48390&action=edit
gcc10-pr94809.patch

Untested fix.

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

* [Bug tree-optimization/94809] [8/9/10 Regression] Different results between gcc-9 and gcc-6
  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
                   ` (4 preceding siblings ...)
  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
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-04-28  7:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
LGTM

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

* [Bug tree-optimization/94809] [8/9/10 Regression] Different results between gcc-9 and gcc-6
  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
                   ` (5 preceding siblings ...)
  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
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-04-28  7:50 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

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

* [Bug tree-optimization/94809] [8/9/10 Regression] Different results between gcc-9 and gcc-6
  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
                   ` (6 preceding siblings ...)
  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
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-04-28  9:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:34f6b14ff33e0c64b3a4a1a2cd871df715d69151

commit r10-8009-g34f6b14ff33e0c64b3a4a1a2cd871df715d69151
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Apr 28 11:26:56 2020 +0200

    tree: Fix up TREE_SIDE_EFFECTS on internal calls [PR94809]

    On the following testcase, match.pd during GENERIC folding
    changes the -1U / x < y into __imag__ .MUL_OVERFLOW (x, y),
    but unfortunately unlike for normal calls nothing sets TREE_SIDE_EFFECTS on
    the call.  There is the process_call_operands function that non-internal
    call creation calls and it is usable for internal calls too,
    e.g. TREE_SIDE_EFFECTS is derived from checking whether the
    call has side-effects (non-ECF_{CONST,PURE}; we have those for internal
    calls) and from whether any of the arguments has TREE_SIDE_EFFECTS.

    2020-04-28  Jakub Jelinek  <jakub@redhat.com>

            PR tree-optimization/94809
            * tree.c (build_call_expr_internal_loc_array): Call
            process_call_operands.

            * gcc.c-torture/execute/pr94809.c: New test.

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

* [Bug tree-optimization/94809] [8/9 Regression] Different results between gcc-9 and gcc-6
  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
                   ` (7 preceding siblings ...)
  2020-04-28  9:28 ` cvs-commit at gcc dot gnu.org
@ 2020-04-28  9:29 ` jakub at gcc dot gnu.org
  2020-09-16 19:21 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-04-28  9:29 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[8/9/10 Regression]         |[8/9 Regression] Different
                   |Different results between   |results between gcc-9 and
                   |gcc-9 and gcc-6             |gcc-6

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed for 10.1 for now.

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

* [Bug tree-optimization/94809] [8/9 Regression] Different results between gcc-9 and gcc-6
  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
                   ` (8 preceding siblings ...)
  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
  11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-09-16 19:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:522022361984407ebc84cde22bdbd199261d0443

commit r9-8888-g522022361984407ebc84cde22bdbd199261d0443
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Apr 28 11:26:56 2020 +0200

    tree: Fix up TREE_SIDE_EFFECTS on internal calls [PR94809]

    On the following testcase, match.pd during GENERIC folding
    changes the -1U / x < y into __imag__ .MUL_OVERFLOW (x, y),
    but unfortunately unlike for normal calls nothing sets TREE_SIDE_EFFECTS on
    the call.  There is the process_call_operands function that non-internal
    call creation calls and it is usable for internal calls too,
    e.g. TREE_SIDE_EFFECTS is derived from checking whether the
    call has side-effects (non-ECF_{CONST,PURE}; we have those for internal
    calls) and from whether any of the arguments has TREE_SIDE_EFFECTS.

    2020-04-28  Jakub Jelinek  <jakub@redhat.com>

            PR tree-optimization/94809
            * tree.c (build_call_expr_internal_loc_array): Call
            process_call_operands.

            * gcc.c-torture/execute/pr94809.c: New test.

    (cherry picked from commit 34f6b14ff33e0c64b3a4a1a2cd871df715d69151)

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

* [Bug tree-optimization/94809] [8/9 Regression] Different results between gcc-9 and gcc-6
  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
                   ` (9 preceding siblings ...)
  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
  11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-09-17 17:38 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed for 8.5 in r8-10494-g1831242824752a6c51f513759830a8667a97f7f2 and by the
above commit for 9.4+ too.

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

* [Bug tree-optimization/94809] [8/9 Regression] Different results between gcc-9 and gcc-6
  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
                   ` (10 preceding siblings ...)
  2020-09-17 17:38 ` jakub at gcc dot gnu.org
@ 2022-03-19  4:16 ` pinskia at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-03-19  4:16 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |141242068 at smail dot nju.edu.cn

--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 104983 has been marked as a duplicate of this bug. ***

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