This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ PATCH] Fix constexpr OBJ_TYPE_REF handling on array elts (PR c++/87398)
- From: Jason Merrill <jason at redhat dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Marek Polacek <polacek at redhat dot com>, gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 25 Sep 2018 10:42:08 -0400
- Subject: Re: [C++ PATCH] Fix constexpr OBJ_TYPE_REF handling on array elts (PR c++/87398)
- References: <20180925071754.GX8250@tucnak>
On Tue, Sep 25, 2018 at 3:17 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> ARRAY_REF is a handled component, so when a virtual call is on an array
> element (or some component thereof), the loop to look through handled
> components will look through the ARRAY_REFs too and then TREE_TYPE (obj)
> might be an ARRAY_TYPE. The code wants to look at the class type instead
> though.
Yeah, I think looping through handled components is wrong here; given
something like
struct A
{
virtual void f();
};
struct B
{
A a;
} b;
int main()
{
b.a.f();
}
Looking through all handled components would give us "b", which has no
virtual functions.
I think we need to be more specific about what we're expecting here.
Jason