Commit fd60b20
authored
fix(__any_allocator): add friend declaration so the cross-specialization converting constructor compiles (NVIDIA#2159)
* fix(__any_allocator): add friend declaration so the cross-specialization converting constructor compiles on MSVC
__any_allocator's converting constructor reads the private member of another
specialization of the same class template, which the standard permits
([class.access], since C++17) but MSVC rejects with C2248. The conversion is
instantiated whenever task_scheduler's type-erased backend copies an
allocator on the heap-allocation fallback path (e.g. with an asio-based
scheduler), so stdexec::task + asio + MSVC currently fails to compile.
Add an explicit friend declaration (harmless on GCC/Clang) and a regression
test that instantiates the converting constructor directly.
Fixes NVIDIA#2158
* docs: correct the rationale — the cross-specialization access is rejected by GCC, Clang and MSVC alike
The converting constructor of __any_allocator reads the private member of
another specialization of the same template. That is rejected by all major
compilers (MSVC C2248; Clang/GCC 'private member' error); upstream never
noticed because the constructor is only instantiated on the heap-allocation
fallback path of task_scheduler (large operation states, e.g. asio-based
schedulers), which the upstream test matrix does not exercise. The friend
declaration makes the conversion legal on every compiler.
* style: fix clang-format violations in test_any_allocator.cpp1 parent 17bf2c4 commit fd60b20
3 files changed
Lines changed: 47 additions & 0 deletions
File tree
- include/stdexec/__detail
- test
- stdexec/detail
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
70 | 76 | | |
71 | 77 | | |
72 | 78 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
0 commit comments