[C++ PATCH] Fix offsetof constexpr handling (PR c++/85662)

Jason Merrill jason@redhat.com
Wed May 9 15:26:00 GMT 2018


On Wed, May 9, 2018 at 10:47 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Wed, May 09, 2018 at 10:40:26AM -0400, Jason Merrill wrote:
>> On Wed, May 9, 2018 at 4:55 AM, Jakub Jelinek <jakub@redhat.com> wrote:
>> > On Tue, May 08, 2018 at 11:28:18PM -0400, Jason Merrill wrote:
>> >> Maybe add a type parameter that defaults to size_type_node...
>> >>
>> >> > +       ret = fold_convert_loc (loc, TREE_TYPE (expr),
>> >> > +                               fold_offsetof_1 (TREE_TYPE (expr), op0));
>> >>
>> >> ...and then this can be
>> >>
>> >>   fold_offsetof (op0, TREE_TYPE (exp0))
>> >
>> > Like this then?
>> >
>> > +       ret = fold_convert_loc (loc, TREE_TYPE (expr),
>> > +                               fold_offsetof (op0, TREE_TYPE (expr)));
>>
>> I was thinking that we then wouldn't need the fold_convert at the call
>> sites anymore, either.
>
> The patch only converts to non-pointer types, I'm not sure if it is
> desirable to do the same with pointer types (and most of the other callers
> don't use convert, but fold_convert which is significantly different, the
> former is emitting diagnostics, the latter is just an conversion + optimization).

Is there a reason we can't use fold_convert for the non-pointer case,
too?  I don't think we're interested in diagnostics from this
particular call.

Jason



More information about the Gcc-patches mailing list