[all-commits] [llvm/llvm-project] 1c6e75: [libc++] Better handling for zero-sized types.
Quuxplusone via All-commits
all-commits at lists.llvm.org
Mon Mar 7 08:51:18 PST 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 1c6e752cfc1a753a0fd04c6201c9c48e477663de
https://github.com/llvm/llvm-project/commit/1c6e752cfc1a753a0fd04c6201c9c48e477663de
Author: Arthur O'Dwyer <arthur.j.odwyer at gmail.com>
Date: 2022-03-07 (Mon, 07 Mar 2022)
Changed paths:
M libcxx/include/__memory/unique_ptr.h
M libcxx/include/__ranges/access.h
A libcxx/test/std/ranges/range.access/begin.sizezero.pass.cpp
A libcxx/test/std/ranges/range.access/end.sizezero.pass.cpp
A libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.sizezero.pass.cpp
Log Message:
-----------
[libc++] Better handling for zero-sized types.
Zero-sized types are a GCC extension, also supported by Clang.
In theory it's already invalid to `delete` a void pointer or a
pointer-to-incomplete, so we shouldn't need any special code
to catch those cases; but in practice Clang accepts both
constructs with just a warning, and GCC even accepts `sizeof(void)`
with just a warning! So we must keep the static_asserts.
The hard errors are tested in `unique_ptr_dltr_dflt/*.compile.fail.cpp`.
In ranges::begin/end, check `sizeof >= 0` instead of `sizeof != 0`,
so as to permit zero-sized types while still disallowing incomplete
types.
Fixes #54100.
Differential Revision: https://reviews.llvm.org/D120633
More information about the All-commits
mailing list