aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/std
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2025-04-24 21:55:16 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2025-04-25 11:47:12 +0100
commit901900bc37566c59b4eb62c1427f3150b800d8a0 (patch)
treedfb367afe60c6d670e5578d8fc7b46a885840c4b /libstdc++-v3/testsuite/std
parent876d1a22dfaf873d167bd2ffad190a1d07a81b22 (diff)
downloadgcc-901900bc37566c59b4eb62c1427f3150b800d8a0.zip
gcc-901900bc37566c59b4eb62c1427f3150b800d8a0.tar.gz
gcc-901900bc37566c59b4eb62c1427f3150b800d8a0.tar.bz2
libstdc++: Improve diagnostics for std::packaged_task invocable checks
Moving the static_assert that checks is_invocable_r_v into _Task_state means it is checked when we instantiate that class template. Replacing the __create_task_state function with a static member function _Task_state::_S_create ensures we instantiate _Task_state and trigger the static_assert immediately, not deep inside the implementation of std::allocate_shared. This results in shorter diagnostics that don't show deeply-nested template instantiations before the static_assert failure. Placing the static_assert at class scope also helps us to fail earlier than waiting until when the _Task_state::_M_run virtual function is instantiated. That also makes the diagnostics shorter and easier to read (although for C++11 and C++14 modes the class-scope static_assert doesn't check is_invocable_r, so dangling references aren't detected until _M_run is instantiated). libstdc++-v3/ChangeLog: * include/std/future (__future_base::_Task_state): Check invocable requirement here. (__future_base::_Task_state::_S_create): New static member function. (__future_base::_Task_state::_M_reset): Use _S_create. (__create_task_state): Remove. (packaged_task): Use _Task_state::_S_create instead of __create_task_state. * testsuite/30_threads/packaged_task/cons/dangling_ref.cc: Adjust dg-error patterns. * testsuite/30_threads/packaged_task/cons/lwg4154_neg.cc: Likewise. Reviewed-by: Tomasz KamiƄski <tkaminsk@redhat.com>
Diffstat (limited to 'libstdc++-v3/testsuite/std')
0 files changed, 0 insertions, 0 deletions