[PATCH] D106784: [ADT] function_ref captures function pointers by value
Chandler Carruth via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 26 18:17:01 PDT 2021
chandlerc added inline comments.
================
Comment at: llvm/include/llvm/ADT/STLExtras.h:168-170
+///
+/// (As an exception, function_ref(&someFreeFunction) is safe, even though the
+/// callable is technically a temporary function pointer).
----------------
The more I think about this the more I feel like we shouldn't try to make this promise... it seems too narrow to be useful. I think maybe if we want to do something here, causing things to break immediately rather than kinda-sorta working is better.
For the code where this came up, I think just moving away from `function_ref` is a much better approach than relying on the special behavior in the case of a pointer.
But happy to defer to dblaikie here ultimately.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D106784/new/
https://reviews.llvm.org/D106784
More information about the llvm-commits
mailing list