public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/98672] New: constexpr function - for loop with return statement doesn't get recognized as constexpr subexpression
@ 2021-01-14  9:17 ryan_greenblatt at brown dot edu
  2021-01-14 11:48 ` [Bug c++/98672] " jakub at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: ryan_greenblatt at brown dot edu @ 2021-01-14  9:17 UTC (permalink / raw)
  To: gcc-bugs

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

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

end of thread, other threads:[~2021-08-28 21:46 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-14  9:17 [Bug c++/98672] New: constexpr function - for loop with return statement doesn't get recognized as constexpr subexpression ryan_greenblatt at brown dot edu
2021-01-14 11:48 ` [Bug c++/98672] " jakub at gcc dot gnu.org
2021-01-21 16:23 ` cvs-commit at gcc dot gnu.org
2021-01-21 16:28 ` jakub at gcc dot gnu.org
2021-01-29 19:19 ` cvs-commit at gcc dot gnu.org
2021-04-20 23:31 ` cvs-commit at gcc dot gnu.org
2021-04-22 14:12 ` jakub at gcc dot gnu.org
2021-08-28 21:45 ` pinskia at gcc dot gnu.org
2021-08-28 21:46 ` pinskia 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).