This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of LEWG status.

4520. Breaking change in std::span new initializer_list constructor

Section: 23.7.2.2.2 [span.cons] Status: LEWG Submitter: Michael Schellenberger Costa Opened: 2026-02-10 Last modified: 2026-02-27

Priority: 1

View other active issues in [span.cons].

View all other issues in [span.cons].

View all issues with LEWG status.

Discussion:

NVIDIA C++ standard library libcu++ received a bug report against our span implementation.

However, looking into this a bit it seems that this is a source-breaking change from the new C++26 initializer_list constructor of span in conjunction with a bad conversion sequence.

The code in question is:

#include <span>

int main() {
  bool data[4] = {true, false, true, false};
  bool* ptr = data;
  size_t size = 4;

  ::std::span<const bool> bad_span{ptr, size};

  return 0;
}

The issue is that the compiler tries a conversion sequence from bool* to bool and size_t to bool.

We probably should disallow conversions to bool by that constructor.

[2026-02-27; Reflector poll.]

Set priority to 1 after reflector poll.

Votes being split between LEWG/P1 and considering this new information from deployment experience, and NAD as the breakage in the paper was already covered in C.1.8 [diff.cpp23.containers]. It was pointed out, that in contrast to the silent change of meaning already discussed with paper, this snippet becomes ill-formed.

Proposed resolution: