[Bug other/12411] Missed -Wsequence-point on functions (example reduced from historical GCC source)

rafael at espindo dot la gcc-bugzilla@gcc.gnu.org
Tue May 12 22:12:40 GMT 2020


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

Rafael Avila de Espindola <rafael at espindo dot la> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rafael at espindo dot la

--- Comment #7 from Rafael Avila de Espindola <rafael at espindo dot la> ---
I think we just hit a case similar to this bug where it would be nice get a
warning.

Given

-------------------------
struct foo {
    void bar(int);
};
foo get_foo(int);
void g() {
    int a = 0;
    get_foo(a).bar(a++);
}
------------------------

GCC will warn about the value of a. If instead of an integer we have an object,
like in

--------------------------------
#include <utility>
struct zed {
    zed();
    zed(const zed&);
    zed(zed&&);
};
struct foo {
    void bar(zed);
};
foo get_foo(zed);
void g() {
    zed a;
    get_foo(a).bar(std::move(a));
}
--------------------------------

GCC produces no warning.

Let me know if I should report a new bug instead.


More information about the Gcc-bugs mailing list