[PATCH] D136554: Implement CWG2631

Jordan Rupprecht via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 22 16:52:35 PST 2022


rupprecht added a comment.

In D136554#4013463 <https://reviews.llvm.org/D136554#4013463>, @rupprecht wrote:

> Glad the test case made sense to you, it was convoluted to me :)
>
> Still seeing one more error, and it's not modules-related so I might be able to get it reduced today. Generally, it looks like this:
>
>   struct Inner {
>     Foo& foo;
>     const std::unique_ptr<...> x = blah(blah(
>         &foo.bar()));
>   };
>   
>   class Outer {
>    private:
>     Foo foo_;
>     Inner inner{foo_};
>   }
>
> With the error being:
>
>   error: 'Inner::foo' is not a member of class 'Outer'
>         &foo.bar()));
>
> I think this build failure is wrong? `foo` should be referring to the definition inside `Inner`, but clang seems to be expecting it to refer to something in `Outer`.
>
> Is it expected that this patch will cause some previously "working" code to no longer build? At some point I expect to hand you a reduction that's actually a bug in the user code.

Fully reduced as:

  template <typename a, typename b> int c(a, b);
  struct d {
    static d e(const char * = __builtin_FILE());
  };
  struct f {
    f(d = d::e());
  };
  struct h {
    int &g;
    int blah = c(g, f());
  };
  struct k {
    k();
    int i;
    h j{i};
  };
  k::k() {}

With the error: `repro.cc:10:16: error: 'h::g' is not a member of class 'k'`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136554/new/

https://reviews.llvm.org/D136554



More information about the cfe-commits mailing list