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
* [Bug c/96549] [10/11 Regression] Wrong evaluation of a comparison between long & short
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 ` marxin at gcc dot gnu.org
2020-08-10 8:20 ` [Bug middle-end/96549] " pinskia at gcc dot gnu.org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-08-10 8:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96549
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
CC| |jakub at gcc dot gnu.org,
| |marxin at gcc dot gnu.org
Last reconfirmed| |2020-08-10
Summary|Wrong evaluation of a |[10/11 Regression] Wrong
|comparison between long & |evaluation of a comparison
|short |between long & short
--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Thank you for the report!
Slighly modified test-case:
long c = -1L;
long b = 0L;
int main(void) {
if (3L > (short) ((c ^= (b = 1L)) * 3L))
return 0;
__builtin_abort ();
}
Started with r10-7921-gbca558de2a24b2a7.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/96549] Wrong evaluation of a comparison between long & short
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 ` pinskia at gcc dot gnu.org
2020-08-10 8:20 ` [Bug middle-end/96549] [10/11 Regression] " pinskia at gcc dot gnu.org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-08-10 8:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96549
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[10/11 Regression] Wrong |Wrong evaluation of a
|evaluation of a comparison |comparison between long &
|between long & short |short
Keywords| |wrong-code
Status|NEW |UNCONFIRMED
Ever confirmed|1 |0
Component|c |middle-end
Last reconfirmed|2020-08-10 00:00:00 |
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/96549] [10/11 Regression] Wrong evaluation of a comparison between long & short
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 ` pinskia at gcc dot gnu.org
2020-08-10 9:10 ` jakub at gcc dot gnu.org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-08-10 8:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96549
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2020-08-10
Ever confirmed|0 |1
Summary|Wrong evaluation of a |[10/11 Regression] Wrong
|comparison between long & |evaluation of a comparison
|short |between long & short
Target Milestone|--- |10.3
Status|UNCONFIRMED |NEW
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/96549] [10/11 Regression] Wrong evaluation of a comparison between long & short
2020-08-10 8:03 [Bug c/96549] New: Wrong evaluation of a comparison between long & short zhige.yu18 at imperial dot ac.uk
` (2 preceding siblings ...)
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
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-08-10 9:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96549
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org
Status|NEW |ASSIGNED
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/96549] [10/11 Regression] Wrong evaluation of a comparison between long & short
2020-08-10 8:03 [Bug c/96549] New: Wrong evaluation of a comparison between long & short zhige.yu18 at imperial dot ac.uk
` (3 preceding siblings ...)
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
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-08-10 9:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96549
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 49033
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49033&action=edit
gcc11-pr96549.patch
Untested fix.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/96549] [10/11 Regression] Wrong evaluation of a comparison between long & short
2020-08-10 8:03 [Bug c/96549] New: Wrong evaluation of a comparison between long & short zhige.yu18 at imperial dot ac.uk
` (4 preceding siblings ...)
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
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-08-11 11:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96549
--- Comment #3 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:6b815e113c9aec397a86d7194f66455eb189cc7a
commit r11-2646-g6b815e113c9aec397a86d7194f66455eb189cc7a
Author: Jakub Jelinek <jakub@redhat.com>
Date: Tue Aug 11 13:46:14 2020 +0200
tree: Fix up get_narrower [PR96549]
My changes to get_narrower to support COMPOUND_EXPRs apparently
used a wrong type for the COMPOUND_EXPRs, while e.g. the rhs
type was unsigned short, the COMPOUND_EXPR got int type as that was the
original type of op. The type of COMPOUND_EXPR should be always the type
of the rhs.
2020-08-11 Jakub Jelinek <jakub@redhat.com>
PR c/96549
* tree.c (get_narrower): Use TREE_TYPE (ret) instead of
TREE_TYPE (win) for COMPOUND_EXPRs.
* gcc.c-torture/execute/pr96549.c: New test.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/96549] [10 Regression] Wrong evaluation of a comparison between long & short
2020-08-10 8:03 [Bug c/96549] New: Wrong evaluation of a comparison between long & short zhige.yu18 at imperial dot ac.uk
` (5 preceding siblings ...)
2020-08-11 11:52 ` cvs-commit at gcc dot gnu.org
@ 2020-08-11 11:53 ` jakub at gcc dot gnu.org
2020-08-25 8:12 ` rguenth at gcc dot gnu.org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-08-11 11:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96549
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[10/11 Regression] Wrong |[10 Regression] Wrong
|evaluation of a comparison |evaluation of a comparison
|between long & short |between long & short
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed on the trunk so far.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/96549] [10 Regression] Wrong evaluation of a comparison between long & short
2020-08-10 8:03 [Bug c/96549] New: Wrong evaluation of a comparison between long & short zhige.yu18 at imperial dot ac.uk
` (6 preceding siblings ...)
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
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-08-25 8:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96549
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/96549] [10 Regression] Wrong evaluation of a comparison between long & short
2020-08-10 8:03 [Bug c/96549] New: Wrong evaluation of a comparison between long & short zhige.yu18 at imperial dot ac.uk
` (7 preceding siblings ...)
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
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-08-25 17:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96549
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:db00336a49707327552e678b59da8e85384bdae6
commit r10-8665-gdb00336a49707327552e678b59da8e85384bdae6
Author: Jakub Jelinek <jakub@redhat.com>
Date: Tue Aug 11 13:46:14 2020 +0200
tree: Fix up get_narrower [PR96549]
My changes to get_narrower to support COMPOUND_EXPRs apparently
used a wrong type for the COMPOUND_EXPRs, while e.g. the rhs
type was unsigned short, the COMPOUND_EXPR got int type as that was the
original type of op. The type of COMPOUND_EXPR should be always the type
of the rhs.
2020-08-11 Jakub Jelinek <jakub@redhat.com>
PR c/96549
* tree.c (get_narrower): Use TREE_TYPE (ret) instead of
TREE_TYPE (win) for COMPOUND_EXPRs.
* gcc.c-torture/execute/pr96549.c: New test.
(cherry picked from commit 6b815e113c9aec397a86d7194f66455eb189cc7a)
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug middle-end/96549] [10 Regression] Wrong evaluation of a comparison between long & short
2020-08-10 8:03 [Bug c/96549] New: Wrong evaluation of a comparison between long & short zhige.yu18 at imperial dot ac.uk
` (8 preceding siblings ...)
2020-08-25 17:45 ` cvs-commit at gcc dot gnu.org
@ 2020-08-25 18:23 ` jakub at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-08-25 18:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96549
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed for 10.3+ too.
^ 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).