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

Adam H. Peterson <alphaetapi at hotmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |alphaetapi at hotmail dot com

--- Comment #1 from Adam H. Peterson <alphaetapi at hotmail dot com> ---
I'm seeing this too, in one of my work projects.  And I also see the odd
results when the variable is used both in the lambda and outside of it.

    #include <iostream>
    template<typename F>
    void run( F &&f ) {
        f(nullptr);
    }
    struct V {
        int i;
    };
    int main() {
        static V const s={2};
        std::cout << s.i << "\n";
        run([](auto){
            std::cout << s.i << "\n" ;
        });
    }

Expected output:
    2
    2
Actual output:
    2
    0

(The in-function use seems to have been inlined, while the lambda continues to
access an uninitialized state.)

Reply via email to