constexpr constructor gives a different result when evaluated at compile time by GCC : <p>The constructor uses a function taking a reference and returning by value while repeatedly modifying a data member:</p>

<pre><code>constexpr int   vv(int   x) {return x;}
constexpr int &amp; rr(int &amp; x) {return x;}
constexpr int   rv(int &amp; x) {return x;}

constexpr struct S {
    int x {0};
    template&lt;typename F&gt; constexpr S(F f) {x = f(x) + 1; x = f(x) + 1;}
} s(rv); // s.x is 1 if function rv is used, 2 otherwise.
static_assert(s.x == 2, "");
</code></pre>

<p>It is only the function <code>rv</code> which gives the unexpected result when used in the constructor. If <code>vv</code> or <code>rr</code> is passed instead then <code>s.x</code> is 2 as expected.</p>

<p>I noticed the behavior on GCC 5.4.1 ARM and it appears to be the same in all versions of GCC that support C++14. Clang gives the expected result of 2 in all cases. Neither GCC nor Clang give any warnings with Wall and Wextra enabled.</p>

<p>Is this example valid C++14 and a bug in GCC? I read the list of restrictions on constant expressions in the standard and see nothing obvious it violates but I'm not sure I understand all the technical details.</p>
