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

--- Comment #8 from Paul Keir <pkeir at outlook dot com> ---
I wonder if a small part of this bug still remains. The code below should
#include <initializer_list>, but as it doesn't, we get an error message. The
message now gives all the right information but, with -std=c++23 and
-std=c++26, a part of the text is still truncated. Instead of "declared here"
we get "is not usable as a 'constexpr' function because:". Perhaps it should
also say "declared here" with -std=c++23 and -std=c++26.

At https://godbolt.org/z/6c9hME7hh the code is:

// #include <initializer_list>

constexpr bool init_list()
{
  int total{};
  for (int x : {1, 2, 3})
    total += x;
  return total == 6;
}

static_assert(init_list(), "");

The error message is:

<source>: In function 'constexpr bool init_list()':
<source>:6:24: error: deducing from brace-enclosed initializer list requires
'#include <initializer_list>'
  +++ |+#include <initializer_list>
    1 | // #include <initializer_list>
......
    6 |   for (int x : {1, 2, 3})
      |                        ^
<source>: At global scope:
<source>:11:24: error: non-constant condition for static assertion
   11 | static_assert(init_list(), "");
      |               ~~~~~~~~~^~
<source>:11:24: error: 'constexpr bool init_list()' called in a constant
expression
<source>:3:16: note: 'constexpr bool init_list()' is not usable as a
'constexpr' function because:
    3 | constexpr bool init_list()
      |                ^~~~~~~~~
Compiler returned: 1

Reply via email to