[PATCH] D133029: [Sema] Allow to diagnose the references to std::vector<T> with incomplete T

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 1 04:46:50 PDT 2022


ilya-biryukov added a comment.

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 */ }


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