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

Matthijs van Duin <matthijsvanduin at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |matthijsvanduin at gmail dot 
com

--- Comment #1 from Matthijs van Duin <matthijsvanduin at gmail dot com> ---
There are many such cases which are well-defined in C++17 yet trigger a
sequence-point warning in g++ 8.2, such as:

(x+i)[i++]
i = i++
(funcs[i++])(i)

This incorrect behaviour is actually documented: "The C++17 standard will
define the order of evaluation of operands in more cases: in particular it
requires that the right-hand side of an assignment be evaluated before the
left-hand side, so the above examples are no longer undefined. But this warning
will still warn about them, to help people avoid writing code that is undefined
in C and earlier revisions of C++."

This reasoning here is of course complete garbage. Plenty of valid C++17 code
is invalid in earlier revisions of the standard. When compiling code with
-std=c++17 or -std=gnu++17, the compiler should only concern itself with
whether the code is valid C++17 code.

Since I think habitually ignoring warnings is very bad practice and compile
with -Werror to ensure this won't happen, I consider these warnings to be
nearly as bad as miscompilation, as the end result is the same: I still cannot
rely on this feature of the C++17 standard.

Reply via email to