[libcxx-commits] [libcxx] [libc++] Provide sized deallocation declarations even when the compiler doesn't support sized deallocation (PR #125577)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Feb 5 01:50:49 PST 2025
philnik777 wrote:
> The compiler's `-fno-sized-deallocation` flag allows controlling whether delete expressions should use sized delete or not, which is a breaking change for some code, since it changes which `operator delete` gets called without making any changes to the user code. AFAIU, that's the purpose of that flag and that's the reason why it wasn't made the default until recently (upstream).
I don't think that's the problem. The sized overload just calls the unsized one by default, so I don't see how that's breaking. My understanding is that the fundamental is that the compiler silently changes to generating calls to functions which may not exist in the runtime yet. That could probably have been solved by using availability information, but most platforms don't have that.
> Some users might be in a situation where they don't want their `delete` expressions to resolve differently, but where it is 100% acceptable to call the sized `operator delete` explicitly. In that case, they could pass `-fno-sized-deallocation` yet still call the library function explicitly (after this patch, but not before).
In what scenario is that the case? Even if I grant that it's a breaking change because allocation replacements may not be aware of the new overload, this can only result in an allocator/deallocator mismatch at that point, which is always a bad idea.
> For availability issues, we have attributes on these declarations: if someone attempts to use a sized `operator delete` while compiling for a target that does not support the functionality, that should be caught at compile-time by these attributes.
Do you mean we'd have them if there are back-deployment problems? Because I can't find any.
https://github.com/llvm/llvm-project/pull/125577
More information about the libcxx-commits
mailing list