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

            Bug ID: 81042
           Summary: Too many constexpr interations on unreachable loop.
           Product: gcc
           Version: 7.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kevincox at kevincox dot ca
  Target Milestone: ---

Created attachment 41526
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41526&action=edit
Example code.

The following code causes an error for too many iterations in the unreachable
loop. Clang correctly creates a binary which returns 1 when run. It's worth
noting that the previous version of gcc I tried this on hung forever, however
7.1.1 gives the too many iterations error.

Example online: https://godbolt.org/g/QFRmwk

$ g++ -std=c++17 test.cc 
/home/kevincox/test.cc: In function ‘int main()’:
/home/kevincox/test.cc:14:24:   in constexpr expansion of ‘foo()’
/home/kevincox/test.cc:7:3: error: constexpr loop iteration count exceeds limit
of 262144 (use -fconstexpr-loop-limit= to increase the limit)
   while (true) {} // Unreachable
   ^~~~~

// test.cc
constexpr static bool foo() {
        int i = 0;
        while (i < 1) {
                i++;
                continue;

                while (true) {} // Unreachable
        }

        return true;
}

int main() {
        constexpr bool f = foo();
        return f;
}

Reply via email to