[Bug libstdc++/66146] call_once not C++11-compliant on ppc64le
lh_mouse at 126 dot com
gcc-bugzilla@gcc.gnu.org
Fri Dec 2 01:25:14 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66146
LIU Hao <lh_mouse at 126 dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |lh_mouse at 126 dot com
--- Comment #53 from LIU Hao <lh_mouse at 126 dot com> ---
Why not implement `call_once` with `__cxa_guard_{acquire,release,abort}`?
It's basically
```
template<typename _Callable, typename... _Args>
void
call_once(once_flag& __once, _Callable&& __callable, _Args&&... __args)
{
int __r = ::__cxa_guard_acquire(&__once);
if(__r == 0)
return; // passive
__try {
_INVOKE(forward<_Callable>(__callable), forward<_Args>(__args)...);
}
__catch(...) {
::__cxa_guard_abort(&__once); // exceptional
__throw_exception_again;
}
::__cxa_guard_release(&__once); // returning
}
```
More information about the Gcc-bugs
mailing list