Sometimes libc++'s stddef.h wrapper gets included, which defines
::nullptr_t. This test is compiled with -Wshadow -Werror, so shadowing
::nullptr_t with a nullptr_t in main is an error. Include cstddef,
which is guaranteed to define std::nullptr_t in C++11 and forward.
Details
- Reviewers
ldionne danalbert - Group Reviewers
Restricted Project - Commits
- rG292533324cad: [libc++abi] Use std::nullptr_t instead of declaring it manually
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
LGTM with drive-by fix.
libcxxabi/test/catch_reference_nullptr.pass.cpp | ||
---|---|---|
9 | While we're at it. |
I don't think this helps, but I don't think it hurts. The correctness of the tests requires std::nullptr_t to be decltype(nullptr), so /shrug
The question is whether the <cstdlib> header is allowed to define a ::nullptr_t. If it does define it (it does with the Android NDK), then the test doesn't compile because -Wshadow complains about the local nullptr_t. (I suspect the issue is that bionic's stdlib.h includes malloc.h, which includes stddef.h without first declaring any __need_* macros. When libc++'s stddef.h is included, it defines ::nullptr_t.) It could be an issue with the bionic headers, but that's also probably hard to clean up without breaking stuff?
I think this change is fine to proceed. Maybe for the super paranoid of us (me), we could static_assert(is_same<std::nullptr_t, decltype(nullptr)>).
That said, you're also free to ignore everything I just said. This test would probably fail if the types weren't the same, and it'll be a very weird day if the bug I'm trying to defend against actually comes to pass.
While we're at it.