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

            Bug ID: 98672
           Summary: constexpr function - for loop with return statement
                    doesn't get recognized as constexpr subexpression
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ryan_greenblatt at brown dot edu
  Target Milestone: ---

https://godbolt.org/z/bEaWhj

```
void not_constexpr() {}

static constexpr int constexpr_loop() {
  for (int i = 0; i < 1; ++i) {
    return i;
  }

  // builds fine with just this:
  // __builtin_unreachable();
  // but not with this:
  not_constexpr();
}

constexpr unsigned i = constexpr_loop();
```
fails with c++14/17/20 on all versions of gcc I tried

Reply via email to