[PATCH] [PR c++/84943] allow folding of array indexing indirect_ref

Jason Merrill jason@redhat.com
Fri Mar 23 16:45:00 GMT 2018


On Fri, Mar 23, 2018 at 12:17 PM, Alexandre Oliva <aoliva@redhat.com> wrote:
> On Mar 23, 2018, Jason Merrill <jason@redhat.com> wrote:
>
>> On Thu, Mar 22, 2018 at 7:00 PM, Alexandre Oliva <aoliva@redhat.com> wrote:
>>> fn[0]() ICEs because we end up with addr_expr of a decl, and that
>>> should only happen for artificial or otherwise special internal
>>> functions.  For anything else, we should find the decl earlier, but we
>>> don't because we build an indirect_ref or an addr_expr and don't
>>> cancel them out.
>
>> That's deliberate; we recently changed the C++ front end to defer most
>> folding until genericization time.
>
> Ok, I can see a number of possibilities as to why this is done, which
> would lead to different choices in the implemnetation of a fix for this
> PR:
>
> a. to mirror the structure of the program as closely as possible

> b. to sort-of mirror the structure of the program for the benefit of
>   operator overloading during template expansion
>
> c. to allow such constructs as *&x to hide symbolic information about x,
>   so that stuff that isn't part of the type system proper (attributes?
>   concepts?) can be "hidden" by such artifacts

Mostly c, as the difference is significant for some language rules.
But in some cases, mainly when we're dealing with internally generated
trees, we do fold.

Seems like cp_fold should update CALL_EXPR_FN with "callee" if non-null.

Jason



More information about the Gcc-patches mailing list