[Bug debug/81042] New: Too many constexpr interations on unreachable loop.

2017-06-09 Thread kevincox at kevincox dot ca
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;
}

[Bug c++/81042] Too many constexpr interations on unreachable loop.

2017-06-09 Thread kevincox at kevincox dot ca
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81042

--- Comment #1 from Kevin Cox  ---
Also it appears the loop condition isn't properly evaluated. For example the
following three examples (and any other number I tested also cause the error.

while (++i == 0) {} // Unreachable
while (++i == 1) {} // Unreachable
while (++i == 2) {} // Unreachable

However some simpler expressions don't cause the error.

while (false) {} // Unreachable
while (i != i) {} // Unreachable