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

--- Comment #1 from Federico Kircheis <federico at kircheis dot it> ---
I looked at some reports at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24639

It seems that most related issues rely on global variables or parameters, but
in fact I found some other examples with local variables

----
void foo(int);

void baz1(){
    int i;
    [&]{++i;}(); // no warning
    foo(i);
}

void baz2(){
    int i;
    ++i; // warning
    foo(i);
}

void baz3(){
    int i;
    int& r = i;
    ++r; // warning
    foo(i);
}

void baz4(){
    int i;
    int& r = i;
    int& rr = r;
    ++rr; // no warning
    foo(i);
}

void baz5(){
    int i;
    struct {int& j;}  r{i};
    ++r.j; // no warning
    foo(i);
}
----


only baz2 and baz3 trigger a warning, in all function a local uninitialized
variable is unconditionally modified.
(the call to function foo is to ensure that the code is not marked as
dead/unused and thus ignored)

Reply via email to