This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/77553] [6/7 Regression] wrong code with post-increment operator in constexpr
- From: "jakub at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 10 Sep 2016 23:14:47 +0000
- Subject: [Bug c++/77553] [6/7 Regression] wrong code with post-increment operator in constexpr
- Auto-submitted: auto-generated
- References: <bug-77553-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77553
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2016-09-10
CC| |jakub at gcc dot gnu.org,
| |jason at gcc dot gnu.org
Target Milestone|--- |6.3
Ever confirmed|0 |1
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The bug is that for POINTER_PLUS_EXPR we do:
case POINTER_PLUS_EXPR:
r = cxx_eval_pointer_plus_expression (ctx, t, lval, non_constant_p,
overflow_p);
if (r)
break;
/* fall through */
...
r = cxx_eval_binary_expression (ctx, t, lval,
non_constant_p, overflow_p);
break;
where both cxx_eval_pointer_plus_expression and cxx_eval_binary_expression
calls cxx_eval_constant_expression on both operands of the POINTER_PLUS_EXPR.
That unfortunately means if the first one returns NULL_TREE, the side-effects
in the two subexpressions happen multiple times.
So, either we should remove cxx_eval_pointer_plus_expression and fold what it
does into cxx_eval_binary_expression, or cxx_eval_pointer_plus_expression
should copy what cxx_eval_binary_expression does, or add some helper function
which will be called only after both operands are processed through
cxx_eval_constant_expression.