Initialising a reference member with itself legal?

Posted by epronk on Stack Overflow See other posts from Stack Overflow or by epronk
Published on 2010-04-08T13:24:47Z Indexed on 2010/04/08 13:43 UTC
Read the original article Hit count: 147

Filed under:

This was a bug I found in a server application using Valgrind.

struct Foo
{
    Foo(const std::string& a)
        : a_(a_)
    {
    }
    const std::string& a_;
};

with gcc -Wall you don't get a warning. Why is this legal code?

© Stack Overflow or respective owner

Related posts about c++