https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119479

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Isn't this just undefined behavior?
Even https://wg21.link/p0145r3 has not specified order of evaluation of
function arguments in C++, and so whether
                        static std::array<size_t, 3> i = { 0, 1, 2 };
                        static std::array<size_t, 3> j = { 2, 1, 0 };
                        return  storage<T,3>::dot_sse(a.pinr(i), b.pinr(i),
c.pinr(i)) -
                                storage<T,3>::dot_sse(a.pinr(j), b.pinr(j),
c.pinr(j));
evaluates a.pinr(i) first (as apparently clang++ does on x86_64 in this case),
then b.pinr(i) and then c.pinr(i) or (as g++ does on x86_64 in this case)
c.pinr(i) first, then b.pinr(i) and then a.pinr(i) or some other order is
unspecified.
And as all 3 modify the same variable (i; same applies to the other call with j
though), this is undefined behavior.
See https://eel.is/c++draft/expr.call#7 and
https://eel.is/c++draft/intro.execution#10

Reply via email to