Repository navigation
Commit 17adb0c
committed
fix(ct2-build): patch MSVC template-arg-deduction crash in decoding.cc:1140
Building CTranslate2 v4.4.0 with MSVC (VS 2022 17.10 / VS 2026
Insiders 18.0) in C++20 mode crashes inside decoding.cc when
decode_alternatives is instantiated. The failing call is:
StorageView input_ids({1, prefix_length},
std::vector<int32_t>(start_tokens.begin(),
start_tokens.begin() + prefix_length),
device);
MSVC's template-arg deduction for the StorageView(Shape, const
std::vector<T>&, Device) ctor fails to bind T=int32_t and instead
tries std::vector<int32_t>::vector<size_t*, size_t*> (treating the
vector as constructed from two iterators), then explodes trying to
deduce the 'value_type' for _Uninitialized_backout_al. GCC and
clang are unaffected — purely MSVC's C++20 deduction.
Workaround: rewrite the call as a 2-step construction. Materialise
the std::vector in a local first, then pass it to StorageView. The
local has a fully-determined type so MSVC's deduction has no
ambiguity to chase:
auto _ct2_prefix_ids = std::vector<int32_t>(start_tokens.begin(),
start_tokens.begin() + prefix_length);
StorageView input_ids({1, prefix_length}, _ct2_prefix_ids, device);
Patch is applied post-FetchContent_MakeAvailable (when ctranslate2-src
is on disk but before its add_subdirectory compiles) via a
string(REPLACE) on decoding.cc, gated on MSVC. GCC and clang see
no change.
Test: \.\ct2-build.cmd\ should now complete on the dev's VS 2026
Insiders host. GCC and clang paths untouched.
Ref: same pattern as the upstream issue tracker would surface
(probably a C++20 modules/concepts regression in MSVC).1 parent 887a734 commit 17adb0c
1 file changed
Lines changed: 29 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
119 | 148 | | |
120 | 149 | | |
121 | 150 | | |
| |||
0 commit comments