[PATCH] D133029: [Sema] Allow to diagnose the references to std::vector<T> with incomplete T
Shafik Yaghmour via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 1 20:32:41 PDT 2022
shafik added a comment.
In D133029#3763688 <https://reviews.llvm.org/D133029#3763688>, @ilya-biryukov wrote:
> In D133029#3763120 <https://reviews.llvm.org/D133029#3763120>, @shafik wrote:
>
>> Do you have an idea of how common this might be?
>
> I don't have the numbers yet, but this broke the builds in C++20 mode inside the core libraries we are using after libc++ change <https://github.com/llvm/llvm-project/commit/98d3d5b5da66e3cf7807c23a0294280bb796466b> that makes vector `constexpr`.
> I suspect every medium-to-large codebase will have a few instances.
> One common pattern that I have seen goes something like:
>
> // foo.h
> struct Inner;
> class Outer {
> std::vector<Inner> elements;
> private:
> size_t size() { return elements.size(); }
> void some_other_method();
> };
>
> struct Inner {
> Outer* outer;
> };
>
> // foo.cpp
> Outer::some_other_method() { /* uses members that would actually fail with incomplete type */ }
This old cfe-dev thread might be relevant: https://lists.llvm.org/pipermail/cfe-dev/2018-June/058338.html
It appears that folks take advantage of this working a lot. It sounds like your saying w/ constexpr std::vector this would be ill-formed in a constant expression context now. Which won't effect most of the existing code I think?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D133029/new/
https://reviews.llvm.org/D133029
More information about the cfe-commits
mailing list