Skip to content

Windows: clang + MSVC STL 14.51 rejects std::find over a 24-byte trivially-comparable type (_Find_vectorized 'unexpected size') #609

Description

@Sunrisepeak

Filing this as a note for later, not a request — the defect is in the toolchain combination, not in mcpp. But mcpp is what puts that combination together on Windows, so this is where a downstream hitting it will look.

What happens

mcpp builds Windows with clang targeting x86_64-pc-windows-msvc — the MSVC ABI, the MSVC STL, and clang as the front end. On a runner image carrying MSVC STL 14.51 (Visual Studio 18), compiling a translation unit that calls std::find over a 24-byte type fails inside the standard library:

xutility:320:23: error: static assertion failed: unexpected size
  320 |         static_assert(false, "unexpected size");
xutility:6542:49: note: in instantiation of function template specialization
  'std::_Find_vectorized<const huxerui::detail::NodeExtensionHandle,
                         huxerui::detail::NodeExtensionHandle>' requested here
 6542 |    _Result = _STD _Find_vectorized(_First_ptr, _Last_ptr, _Val);

The element type is unremarkable:

struct NodeExtensionHandle {
  std::uint64_t             node_identity   = 0;   // 8
  std::size_t               extension_index = 0;   // 8
  const ModifierDescriptor* descriptor      = nullptr;  // 8
  bool operator==(const NodeExtensionHandle&) const = default;
};

24 bytes, no padding, trivially copyable, defaulted operator==.

Why it happens

MSVC STL's vectorized std::find is guarded by a trait deciding whether the element type can be compared bitwise. That guard admits this type under clang, and the helper it then dispatches to implements the 1/2/4/8-byte cases and static_asserts on everything else. Guard and implementation disagree about what "vectorizable" means, and only clang is present to notice — MSVC's own front end does not take this path.

It is version-specific, and that is the useful part

image MSVC STL same source, same clang
windows-2022 14.3x compiles
windows-latest (VS 18) 14.51 static_assert failure

So it is not the package's code and not a descriptor problem — it is this STL release against clang.

Blast radius, measured

On the mcpp-index shard where this surfaced, 13 of 14 members compiled fine on the 14.51 image; one did not. So it is narrow — it only bites code that instantiates std::find over a trivially-comparable type larger than 8 bytes. The narrowness is what makes it awkward: on a rolling image label, the set of affected packages changes underneath you, and the failure shows up attributed to whichever descriptor happened to change that week.

What was done downstream

mcpp-index pinned its Windows leg from windows-latest to windows-2022 (mcpplibs/mcpp-index#385), which is also what the affected project's own mcpp CI already does. That is a workaround, not a fix, and the pin should be lifted once clang and MSVC STL agree again.

Why it is filed here

Nothing for mcpp to change today. But anyone who hits this will hit it through mcpp build on Windows and will reasonably start here, and the error points into <xutility> with no hint that the STL version is the variable. A note in this tracker is the cheapest way to shorten that search. Feel free to close or relabel as upstream-tracking.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions