public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/101508] New: Possible undefined behaviour in cpp program using "unsigned" type starting from GCC 9
@ 2021-07-19 10:25 pnarsing at mathworks dot com
2021-07-19 10:46 ` [Bug tree-optimization/101508] [9/10/11/12 Regression] Possible undefined behaviour in cpp program using "unsigned" type starting with r9-4145 jakub at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: pnarsing at mathworks dot com @ 2021-07-19 10:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101508
Bug ID: 101508
Summary: Possible undefined behaviour in cpp program using
"unsigned" type starting from GCC 9
Product: gcc
Version: 10.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: pnarsing at mathworks dot com
Target Milestone: ---
Hi Team,
I'm observing an optimization issue while compiling with GCC 10.3 .
On investigating figured that issue is reproducible in GCC 9 as well .
This can be reproduced by simple test code mentioned below :
------------------------------------------------------
using int_type = unsigned int; // works without "unsigned"
int_type constexpr start{0}; // works if >= 1
int_type constexpr stop{3}; // works if <= 2
int_type constexpr mult{2}; // works if != 2
int main()
{
int result = 0;
for(int_type aa = start; aa < stop; ++aa)
{
int_type const bb = aa * mult; // works if volatile
if (aa > bb)
{
return 99;
}
++result;
}
return result; // should be == stop
}
----------------------------------------------------------------
This code snippet returns 99 instead of 3 .
You can check the following link to see the issue reproducibility:
https://godbolt.org/z/zd79PPKfn
Modifying compiler option to -O1 and -Og avoids the issue.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/101508] [9/10/11/12 Regression] Possible undefined behaviour in cpp program using "unsigned" type starting with r9-4145
2021-07-19 10:25 [Bug tree-optimization/101508] New: Possible undefined behaviour in cpp program using "unsigned" type starting from GCC 9 pnarsing at mathworks dot com
@ 2021-07-19 10:46 ` jakub at gcc dot gnu.org
2021-07-19 11:00 ` rguenth at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-07-19 10:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101508
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |amker at gcc dot gnu.org
Status|UNCONFIRMED |NEW
Last reconfirmed| |2021-07-19
Summary|Possible undefined |[9/10/11/12 Regression]
|behaviour in cpp program |Possible undefined
|using "unsigned" type |behaviour in cpp program
|starting from GCC 9 |using "unsigned" type
| |starting with r9-4145
Target Milestone|--- |9.5
Ever confirmed|0 |1
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r9-4145-ga81e2c6240655f60a49c16e0d8bbfd2ba40bba51
Simplified C testcase:
int
main ()
{
unsigned i;
for (i = 0; i < 3; ++i)
{
if (i > i * 2)
__builtin_abort ();
}
return 0;
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/101508] [9/10/11/12 Regression] Possible undefined behaviour in cpp program using "unsigned" type starting with r9-4145
2021-07-19 10:25 [Bug tree-optimization/101508] New: Possible undefined behaviour in cpp program using "unsigned" type starting from GCC 9 pnarsing at mathworks dot com
2021-07-19 10:46 ` [Bug tree-optimization/101508] [9/10/11/12 Regression] Possible undefined behaviour in cpp program using "unsigned" type starting with r9-4145 jakub at gcc dot gnu.org
@ 2021-07-19 11:00 ` rguenth at gcc dot gnu.org
2022-01-17 14:02 ` rguenth at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-19 11:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101508
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Depends on| |100740
Keywords| |wrong-code
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
This one is resolved with the (bogus) fix for PR100740
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100740
[Bug 100740] [9/10/11/12 Regression] wrong code at -O1 and above on
x86_64-linux-gnu since r9-4145
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/101508] [9/10/11/12 Regression] Possible undefined behaviour in cpp program using "unsigned" type starting with r9-4145
2021-07-19 10:25 [Bug tree-optimization/101508] New: Possible undefined behaviour in cpp program using "unsigned" type starting from GCC 9 pnarsing at mathworks dot com
2021-07-19 10:46 ` [Bug tree-optimization/101508] [9/10/11/12 Regression] Possible undefined behaviour in cpp program using "unsigned" type starting with r9-4145 jakub at gcc dot gnu.org
2021-07-19 11:00 ` rguenth at gcc dot gnu.org
@ 2022-01-17 14:02 ` rguenth at gcc dot gnu.org
2022-01-24 12:15 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-17 14:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101508
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/101508] [9/10/11/12 Regression] Possible undefined behaviour in cpp program using "unsigned" type starting with r9-4145
2021-07-19 10:25 [Bug tree-optimization/101508] New: Possible undefined behaviour in cpp program using "unsigned" type starting from GCC 9 pnarsing at mathworks dot com
` (2 preceding siblings ...)
2022-01-17 14:02 ` rguenth at gcc dot gnu.org
@ 2022-01-24 12:15 ` cvs-commit at gcc dot gnu.org
2022-01-24 12:44 ` [Bug tree-optimization/101508] [9/10/11 " rguenth at gcc dot gnu.org
2022-01-24 12:46 ` rguenth at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-01-24 12:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101508
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:
https://gcc.gnu.org/g:f1af8528d34418bc874ae9d993ee0dc3559972d2
commit r12-6844-gf1af8528d34418bc874ae9d993ee0dc3559972d2
Author: Richard Biener <rguenther@suse.de>
Date: Mon Jan 24 11:50:06 2022 +0100
tree-optimization/102131 - fix niter analysis wrt overflow
This fixes the overflow issues seen with analyzing
BASE0 + STEP0 cmp BASE1 + STEP1 as BASE0 + STEP0 - STEP1 cmp BASE1
by following the logic we have when simplifying comparisons.
2022-01-24 Richard Biener <rguenther@suse.de>
Jiufu Guo <guojiufu@linux.ibm.com>
PR tree-optimization/100740
PR tree-optimization/101508
PR tree-optimization/101972
PR tree-optimization/102131
* tree-ssa-loop-niter.cc (number_of_iterations_cond): Properly
constrain BASE0 + STEP0 cmp BASE1 + STEP1 to
BASE0 + STEP0 - STEP1 cmp BASE1 transform.
* gcc.dg/torture/pr100740.c: New testcase.
* gcc.dg/torture/pr101508.c: Likewise.
* gcc.dg/torture/pr101972.c: Likewise.
* gcc.dg/torture/pr102131-1.c: Likewise.
* gcc.dg/torture/pr102131-2.c: Likewise.
* gcc.dg/torture/pr102131-3.c: Likewise.
* gcc.dg/torture/pr102131-4.c: Likewise.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/101508] [9/10/11 Regression] Possible undefined behaviour in cpp program using "unsigned" type starting with r9-4145
2021-07-19 10:25 [Bug tree-optimization/101508] New: Possible undefined behaviour in cpp program using "unsigned" type starting from GCC 9 pnarsing at mathworks dot com
` (3 preceding siblings ...)
2022-01-24 12:15 ` cvs-commit at gcc dot gnu.org
@ 2022-01-24 12:44 ` rguenth at gcc dot gnu.org
2022-01-24 12:46 ` rguenth at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-24 12:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101508
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[9/10/11/12 Regression] |[9/10/11 Regression]
|Possible undefined |Possible undefined
|behaviour in cpp program |behaviour in cpp program
|using "unsigned" type |using "unsigned" type
|starting with r9-4145 |starting with r9-4145
Status|NEW |ASSIGNED
Known to work| |12.0
Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/101508] [9/10/11 Regression] Possible undefined behaviour in cpp program using "unsigned" type starting with r9-4145
2021-07-19 10:25 [Bug tree-optimization/101508] New: Possible undefined behaviour in cpp program using "unsigned" type starting from GCC 9 pnarsing at mathworks dot com
` (4 preceding siblings ...)
2022-01-24 12:44 ` [Bug tree-optimization/101508] [9/10/11 " rguenth at gcc dot gnu.org
@ 2022-01-24 12:46 ` rguenth at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-24 12:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101508
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |DUPLICATE
Status|ASSIGNED |RESOLVED
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Dup.
*** This bug has been marked as a duplicate of bug 100740 ***
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-01-24 12:46 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-19 10:25 [Bug tree-optimization/101508] New: Possible undefined behaviour in cpp program using "unsigned" type starting from GCC 9 pnarsing at mathworks dot com
2021-07-19 10:46 ` [Bug tree-optimization/101508] [9/10/11/12 Regression] Possible undefined behaviour in cpp program using "unsigned" type starting with r9-4145 jakub at gcc dot gnu.org
2021-07-19 11:00 ` rguenth at gcc dot gnu.org
2022-01-17 14:02 ` rguenth at gcc dot gnu.org
2022-01-24 12:15 ` cvs-commit at gcc dot gnu.org
2022-01-24 12:44 ` [Bug tree-optimization/101508] [9/10/11 " rguenth at gcc dot gnu.org
2022-01-24 12:46 ` rguenth 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).