public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/113595] New: Confusing 'goto' is not a constant expression error message in constructor at compile time
@ 2024-01-25  8:10 hewillk at gmail dot com
  2024-01-25  8:17 ` [Bug c++/113595] [C++14/17]Confusing " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: hewillk at gmail dot com @ 2024-01-25  8:10 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 113595
           Summary: Confusing 'goto' is not a constant expression error
                    message in constructor at compile time
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hewillk at gmail dot com
  Target Milestone: ---

template<int N>
struct MyArr {
  constexpr MyArr(const int (&arr)[N]) {
    for (int i = 0; i < N; i++)
      arr_[i] = arr[i];
  }
  int arr_[N];
};

constexpr int arr[10] = {};
constexpr MyArr<10> my_arr(arr);

https://godbolt.org/z/978rTjqGP

---------------

GCC correctly (I think) rejects the above code, but the error message is a bit
confusing:

<source>:4:5: error: 'goto' is not a constant expression
    4 |     for (int i = 0; i < N; i++)
      |     ^~~

since there is no 'goto' in the code.

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

end of thread, other threads:[~2024-01-25  8:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-25  8:10 [Bug c++/113595] New: Confusing 'goto' is not a constant expression error message in constructor at compile time hewillk at gmail dot com
2024-01-25  8:17 ` [Bug c++/113595] [C++14/17]Confusing " 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).