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

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

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

Priority: Not Prioritized

View other active issues in [span.cons].

View all other issues in [span.cons].

View all issues with New 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.

Proposed resolution: