public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/97627] New: loop end condition missing - endless loop
@ 2020-10-29 11:32 marcin.jachu19 at gmail dot com
  2020-10-29 12:19 ` [Bug c++/97627] [9/10/11 Regression] loop end condition missing - endless loop with -fPIC rguenth at gcc dot gnu.org
                   ` (17 more replies)
  0 siblings, 18 replies; 19+ messages in thread
From: marcin.jachu19 at gmail dot com @ 2020-10-29 11:32 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97627
           Summary: loop end condition missing - endless loop
           Product: gcc
           Version: 9.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marcin.jachu19 at gmail dot com
  Target Milestone: ---

Created attachment 49467
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49467&action=edit
cpp source file

It seems a loop end condition is missing in this example. Observed on gcc 9.x
and 10.x (all versions). 
This example may look as not much sense, but it is extracted from bigger system
to just explore the issue.

GCC version (in practice any 9.x and 10.x):
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-9.2.0/configure --enable-languages=c,c++
--enable-multilib
Thread model: posix
gcc version 9.2.0 (GCC)
GNU C++17 (GCC) version 9.2.0 (x86_64-pc-linux-gnu)
        compiled by GNU C version 9.2.0, GMP version 4.3.1, MPFR version 2.4.1,
MPC version 0.8, isl version none

System type (doesn't matter, any Linux, for this example used):
centos-release-7-7.1908.0.el7.centos.x86_64

GCC compilation options:
../gcc-9.2.0/configure --enable-languages=c,c++ --enable-multilib

Test compilation options:
g++ -Wall -Wextra -fPIC -O2 -std=c++17 -o test test.cpp

Compiler output:
(none)

Source files attached, the problematic loop:

for (int h = 0; h < num_of_repeats_h; h++)
{
    for (int w = 0; w < num_of_repeats_w; w++)
    {
        printf("w: %d, num_of_repeats_w: %d\n", w, num_of_repeats_w);
    }
}

Expected behavior:
test enters to the inter loop only once, printing counter always equal 0 like:
w: 0, num_of_repeats_w: 1

Actual behavior:
the internal loop never ends, the counter reaches high numbers like:
w: 22373, num_of_repeats_w: 1

Command line
./test
Ctrl+c

More comments:
- gcc 8.x works OK on this example
- it's worth to mention, that -fwrapv option makes it working fine, but I
believe the issue just hides.
- also the -O1 option makes the difference.
- also the -fsanitize=undefined option makes the difference like:
<unknown>: runtime error: execution reached an unreachable program point
but I still believe the source code is correct and the gcc causes the issue.

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

end of thread, other threads:[~2021-01-29 11:51 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-29 11:32 [Bug c++/97627] New: loop end condition missing - endless loop marcin.jachu19 at gmail dot com
2020-10-29 12:19 ` [Bug c++/97627] [9/10/11 Regression] loop end condition missing - endless loop with -fPIC rguenth at gcc dot gnu.org
2020-10-29 12:21 ` jakub at gcc dot gnu.org
2020-10-29 12:26 ` jakub at gcc dot gnu.org
2020-10-29 12:32 ` jakub at gcc dot gnu.org
2020-10-29 12:56 ` amker at gcc dot gnu.org
2020-10-30 11:29 ` rguenth at gcc dot gnu.org
2020-11-03 13:14 ` rguenth at gcc dot gnu.org
2020-11-03 13:15 ` rguenth at gcc dot gnu.org
2021-01-21 12:07 ` jakub at gcc dot gnu.org
2021-01-21 12:24 ` amker at gcc dot gnu.org
2021-01-25 11:19 ` amker at gcc dot gnu.org
2021-01-25 11:29 ` amker at gcc dot gnu.org
2021-01-25 11:32 ` amker at gcc dot gnu.org
2021-01-29 11:01 ` [Bug tree-optimization/97627] " cvs-commit at gcc dot gnu.org
2021-01-29 11:08 ` [Bug tree-optimization/97627] [9 " rguenth at gcc dot gnu.org
2021-01-29 11:09 ` cvs-commit at gcc dot gnu.org
2021-01-29 11:51 ` cvs-commit at gcc dot gnu.org
2021-01-29 11:51 ` 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).