Build fails on macOS 10.15: `ThreadLocal.h: error: no matching constructor for initialization of 'std::function<LocalRefCount ()>'`
- Dominant language
- C++
- Stars
- 30.5k
- Forks
- 5.9k
- PR merge metrics
- No merged PRs in 30d
Description
```
In file included from /opt/local/var/macports/build/_opt_CatalinaPorts_devel_folly/folly/work/folly-v2024.07.22.00/folly/Singleton.cpp:17:
In file included from /opt/local/var/macports/build/_opt_CatalinaPorts_devel_folly/folly/work/folly-v2024.07.22.00/folly/Singleton.h:134:
In file included from /opt/local/var/macports/build/_opt_CatalinaPorts_devel_folly/folly/work/folly-v2024.07.22.00/folly/concurrency/CoreCachedSharedPtr.h:27:
In file included from /opt/local/var/macports/build/_opt_CatalinaPorts_devel_folly/folly/work/folly-v2024.07.22.00/folly/synchronization/Hazptr.h:20:
In file included from /opt/local/var/macports/build/_opt_CatalinaPorts_devel_folly/folly/work/folly-v2024.07.22.00/folly/synchronization/HazptrDomain.h:29:
In file included from /opt/local/var/macports/build/_opt_CatalinaPorts_devel_folly/folly/work/folly-v2024.07.22.00/folly/synchronization/HazptrThrLocal.h:27:
In file included from /opt/local/var/macports/build/_opt_CatalinaPorts_devel_folly/folly/work/folly-v2024.07.22.00/folly/SingletonThreadLocal.h:25:
/opt/local/var/macports/build/_opt_CatalinaPorts_devel_folly/folly/work/folly-v2024.07.22.00/folly/ThreadLocal.h:74:9: error: no matching constructor for initialization of 'std::function'
74 | : constructor_(std::forward(constructor)) {}
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/local/var/macports/build/_opt_CatalinaPorts_devel_folly/folly/work/folly-v2024.07.22.00/folly/concurrency/memory/TLRefCount.h:30:9: note: in instantiation of function template specialization 'folly::ThreadLocal::ThreadLocal<(lambda at /opt/local/var/macports/build/_opt_CatalinaPorts_devel_folly/folly/work/folly-v2024.07.22.00/folly/concurrency/memory/TLRefCount.h:30:21), 0>' requested here
30 | : localCount_([&]() { return LocalRefCount(*this); }),
| ^
/opt/local/include/libcxx/v1/functional:2366:5: note: candidate constructor not viable: no known conversion from '(lambda at /opt/local/var/macports/build/_opt_CatalinaPorts_devel_folly/folly/work/folly-v2024.07.22.00/folly/concurrency/memory/TLRefCount.h:30:21)' to 'nullptr_t' (aka 'std::nullptr_t') for 1st argument
2366 | function(nullptr_t) _NOEXCEPT {}
| ^ ~~~~~~~~~
/opt/local/include/libcxx/v1/functional:2367:5: note: candidate constructor not viable: no known conversion from '(lambda at /opt/local/var/macports/build/_opt_CatalinaPorts_devel_folly/folly/work/folly-v2024.07.22.00/folly/concurrency/memory/TLRefCount.h:30:21)' to 'const function' for 1st argument
2367 | function(const function&);
| ^ ~~~~~~~~~~~~~~~
/opt/local/include/libcxx/v1/functional:2368:5: note: candidate constructor not viable: no known conversion from '(lambda at /opt/local/var/macports/build/_opt_CatalinaPorts_devel_folly/folly/work/folly-v2024.07.22.00/folly/concurrency/memory/TLRefCount.h:30:21)' to 'function' for 1st argument
2368 | function(function&&) _NOEXCEPT;
| ^ ~~~~~~~~~~
/opt/local/include/libcxx/v1/functional:2370:5: note: candidate template ignored: requirement '__callable<(lambda at /opt/local/var/macports/build/_opt_CatalinaPorts_devel_folly/folly/work/folly-v2024.07.22.00/folly/concurrency/memory/TLRefCount.h:30:21) &, true>::value' was not satisfied [with _Fp = (lambda at /opt/local/var/macports/build/_opt_CatalinaPorts_devel_folly/folly/work/folly-v2024.07.22.00/folly/concurrency/memory/TLRefCount.h:30:21)]
2370 | function(_Fp);
| ^
/opt/local/include/libcxx/v1/functional:2364:5: note: candidate constructor not viable: requires 0 arguments, but 1 was provided
2364 | function() _NOEXCEPT { }
| ^
1 error generated.
```
Contributor guide
Research direction
Start with folly/ThreadLocal.h:74 and folly/concurrency/memory/TLRefCount.h:30, then reproduce the reported build on macOS 10.15 with its libc++ implementation. Trace why the lambda cannot initialize std::function and verify that the affected Folly build completes successfully on that platform.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, macos
- Domain
- build-system, operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 38/100