Re: [PATCH] [PR c++/85437] accept static_casted ptrmem in constexpr

2018-04-24 Thread Jason Merrill
On Tue, Apr 24, 2018 at 12:31 PM, Nathan Sidwell wrote: > On 04/23/2018 01:19 PM, Jason Merrill wrote: >> >> On Fri, Apr 20, 2018, 12:52 PM Nathan Sidwell > >> I have to change convert_ptrmem to always >> expand the constant (into an OFFSET_TYPE) so that

Re: [PATCH] [PR c++/85437] accept static_casted ptrmem in constexpr

2018-04-24 Thread Nathan Sidwell
Now with added patchy goodness. On 04/24/2018 12:31 PM, Nathan Sidwell wrote: On 04/23/2018 01:19 PM, Jason Merrill wrote: On Fri, Apr 20, 2018, 12:52 PM Nathan Sidwell

Re: [PATCH] [PR c++/85437] accept static_casted ptrmem in constexpr

2018-04-24 Thread Nathan Sidwell
On 04/23/2018 01:19 PM, Jason Merrill wrote: On Fri, Apr 20, 2018, 12:52 PM Nathan Sidwell

Re: [PATCH] [PR c++/85437] accept static_casted ptrmem in constexpr

2018-04-23 Thread Jason Merrill
On Fri, Apr 20, 2018, 12:52 PM Nathan Sidwell wrote: > On 04/20/2018 01:44 PM, Jason Merrill wrote: > > > Any time we need an actual adjustment, there will be a PLUS_EXPR. The > > issue is somehow distinguishing between a reinterpret_cast and one of > > the many other sources of

Re: [PATCH] [PR c++/85437] accept static_casted ptrmem in constexpr

2018-04-20 Thread Jakub Jelinek
On Fri, Apr 20, 2018 at 02:52:32PM -0400, Nathan Sidwell wrote: > On 04/20/2018 01:44 PM, Jason Merrill wrote: > > > Any time we need an actual adjustment, there will be a PLUS_EXPR. The > > issue is somehow distinguishing between a reinterpret_cast and one of > > the many other sources of

Re: [PATCH] [PR c++/85437] accept static_casted ptrmem in constexpr

2018-04-20 Thread Nathan Sidwell
On 04/20/2018 01:44 PM, Jason Merrill wrote: Any time we need an actual adjustment, there will be a PLUS_EXPR. The issue is somehow distinguishing between a reinterpret_cast and one of the many other sources of NOP_EXPR. yeah, I see that now. Perhaps VIEW_CONVERT_EXPR is more appropriate

Re: [PATCH] [PR c++/85437] accept static_casted ptrmem in constexpr

2018-04-20 Thread Jason Merrill
On Fri, Apr 20, 2018, 8:28 AM Nathan Sidwell wrote: > On 04/18/2018 01:07 AM, Jason Merrill wrote: > > I wonder if it would work to use CONVERT_EXPR for reinterpret_cast. > > That's kind of the wrong way round, isn't it? NOP_EXPRs are for things > that don't generate code, which

Re: [PATCH] [PR c++/85437] accept static_casted ptrmem in constexpr

2018-04-20 Thread Nathan Sidwell
On 04/18/2018 01:07 AM, Jason Merrill wrote: I wonder if it would work to use CONVERT_EXPR for reinterpret_cast. That's kind of the wrong way round, isn't it? NOP_EXPRs are for things that don't generate code, which a reinterpret_cast is. static_cast adds a constant, which is only zero for

Re: [PATCH] [PR c++/85437] accept static_casted ptrmem in constexpr

2018-04-19 Thread Jakub Jelinek
On Wed, Apr 18, 2018 at 09:32:53PM +0200, Jakub Jelinek wrote: > In any case, this reinterpret_cast constexpr pedantic stuff looks too > large/risky at this point to me, I wonder if we accept-invalid even the > simple constexpr int a = reinterpret_cast (1); whether it is not ok for > GCC8 to not

Re: [PATCH] [PR c++/85437] accept static_casted ptrmem in constexpr

2018-04-18 Thread Jakub Jelinek
On Wed, Apr 18, 2018 at 03:14:19PM +0200, Jakub Jelinek wrote: > On Wed, Apr 18, 2018 at 02:59:34PM +0200, Jakub Jelinek wrote: > > On Wed, Apr 18, 2018 at 05:07:33AM +, Jason Merrill wrote: > > > I wonder if it would work to use CONVERT_EXPR for reinterpret_cast. > > As for reinterpret_cast,

Re: [PATCH] [PR c++/85437] accept static_casted ptrmem in constexpr

2018-04-18 Thread Jakub Jelinek
On Wed, Apr 18, 2018 at 02:59:34PM +0200, Jakub Jelinek wrote: > On Wed, Apr 18, 2018 at 05:07:33AM +, Jason Merrill wrote: > > I wonder if it would work to use CONVERT_EXPR for reinterpret_cast. As for reinterpret_cast, we e.g. accept constexpr int a = reinterpret_cast (1); which clang++

Re: [PATCH] [PR c++/85437] accept static_casted ptrmem in constexpr

2018-04-18 Thread Jakub Jelinek
On Wed, Apr 18, 2018 at 05:07:33AM +, Jason Merrill wrote: > I wonder if it would work to use CONVERT_EXPR for reinterpret_cast. I have tried following (still need Alex' expr.c changes, otherwise it ICEs), on the bright side it fixes the new pr85437-4.C testcase, but it causes Excess errors:

Re: [PATCH] [PR c++/85437] accept static_casted ptrmem in constexpr

2018-04-17 Thread Jason Merrill
I wonder if it would work to use CONVERT_EXPR for reinterpret_cast. On Tue, Apr 17, 2018, 9:45 PM Alexandre Oliva wrote: > > A static_cast of a pointer to data member used to wrap the PTRMEM_CST > in a NOP_EXPR, but the NOP_EXPR is taken, in constexpr, as evidence > that

[PATCH] [PR c++/85437] accept static_casted ptrmem in constexpr

2018-04-17 Thread Alexandre Oliva
A static_cast of a pointer to data member used to wrap the PTRMEM_CST in a NOP_EXPR, but the NOP_EXPR is taken, in constexpr, as evidence that there was a reinterpret_cast in the expression. While reinterpret_casts are to be rejected in constexprs, static_casts are ok. Thus, avoid introducing