On Mon, Jul 18, 2016 at 2:33 PM, Jakub Jelinek <ja...@redhat.com> wrote:
> On Mon, Jul 18, 2016 at 02:07:50PM -0400, Jason Merrill wrote:
>> >    /* Fold away the NOP_EXPR from fold_builtin_n.  */
>> >    new_call = fold (new_call);
>> >    force_folding_builtin_constant_p = save_ffbcp;
>> > +
>> > +  /* Folding some math builtins produces e.g. COMPOUND_EXPR etc.  */
>> > +  if (cxx_dialect >= cxx14)
>> > +    return cxx_eval_constant_expression (&new_ctx, new_call, lval,
>> > +                                        non_constant_p, overflow_p);
>>
>> If we do this unconditionally, can we drop the fold above?
>
> So I've tried following patch, but on
> extern "C" double frexp (double, int *);
>
> struct S
> {
> #ifdef FREXP
>   constexpr S (double a) : y {}, x (frexp (a, &y)) {}
> #else
>   constexpr S (double a) : y {}, x ((y = 1, 0.8125)) {}
> #endif
>   double x;
>   int y;
> };
>
> static_assert (S (6.5).x == 0.8125, "");
>
> it means the testcase is accepted with -DFREXP in both
> -std=gnu++11 and -std=gnu++14 modes and without -DFREXP in
> -std=gnu++14 mode only.  I can move over the fold call
> to the cxx11 block, but I think we need to reject it for C++11.

Ah, I guess we need to check cxx_dialect in cxx_eval_store_expression,
not just in potential_constant_expression.

Jason

Reply via email to