Skip to content

Commit 3c5df58

Browse files
authored
[Windows] Fix native build failure on the VS 2026 toolset (#1539)
The `windows-2025` GitHub Actions runner provisions Visual Studio 2026 (v18) alongside VS 2022, and `gha-setup-vsdevenv` selects the newest install via `vswhere -latest`. The v18 `constexpr` evaluator crashes with an Internal Compiler Error (C1001) while instantiating node-addon-api's templated `InstanceAccessor<&Fn>()` helper (`napi-inl.h`), which takes the getter as a `constexpr` member-pointer template argument. Replace the templated accessor with the equivalent runtime overload in `ref-napi`'s `PointerBuffer::Init`: - `InstanceAccessor<&PointerBuffer::Length>("length")` + `InstanceAccessor("length", &PointerBuffer::Length, nullptr)` The runtime overload passes the getter as a plain function pointer and the setter as `nullptr`, preserving the read-only `length` accessor exactly while avoiding the `constexpr` template path that trips the ICE. This compiles cleanly on every platform/toolset and is a no-op at runtime. Fix: #1538
1 parent 04822d0 commit 3c5df58

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

third_party/ref-napi/src/ref_napi_bindings.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,22 @@ class PointerBuffer : public ObjectWrap<PointerBuffer> {
100100
};
101101

102102
Object PointerBuffer::Init(Napi::Env env, Object exports) {
103-
Function func =
104-
DefineClass(env, "PointerBuffer",
105-
{InstanceMethod("isNull", &PointerBuffer::IsNull),
106-
InstanceMethod("get", &PointerBuffer::Get),
107-
InstanceMethod("address", &PointerBuffer::Address),
108-
InstanceMethod("toString", &PointerBuffer::ToString),
109-
InstanceMethod("copy", &PointerBuffer::Copy),
110-
InstanceMethod("slice", &PointerBuffer::Slice),
111-
InstanceAccessor<&PointerBuffer::Length>("length")});
103+
Function func = DefineClass(
104+
env, "PointerBuffer",
105+
{InstanceMethod("isNull", &PointerBuffer::IsNull),
106+
InstanceMethod("get", &PointerBuffer::Get),
107+
InstanceMethod("address", &PointerBuffer::Address),
108+
InstanceMethod("toString", &PointerBuffer::ToString),
109+
InstanceMethod("copy", &PointerBuffer::Copy),
110+
InstanceMethod("slice", &PointerBuffer::Slice),
111+
// Use the runtime InstanceAccessor(name, getter, setter)
112+
// overload rather than the templated
113+
// InstanceAccessor<&Fn>() form: the latter's constexpr
114+
// member-pointer template argument triggers an MSVC
115+
// Internal Compiler Error (C1001) on the VS 2026 (v18)
116+
// toolset used by the windows-2025 CI runner. This form
117+
// is equivalent and compiles cleanly on every platform.
118+
InstanceAccessor("length", &PointerBuffer::Length, nullptr)});
112119

113120
exports.Set("PointerBuffer", func);
114121
InstanceData* data = InstanceData::Get(env);

0 commit comments

Comments
 (0)