VC++ Warning C4356: static data member cannot be initialized via derived class
<p>The following code issues this warning, but it seems to work fine as both A::st and B::st are initialized and actually represent the same string. In my understanding this is malformed code and it should not compile (I checked clang). I wonder why VC++ doesn't issue an error instead of a warning?</p>

<pre><code>#include &lt;string&gt;
#include &lt;iostream&gt;

class A
{
public:
    static const std::string st;
};

class B : public A
{

};

const std::string B::st = "abcd"; //warning C4356: 'A::st': static data member cannot be initialized via derived class

int main()
{
    std::cout &lt;&lt; A::st &lt;&lt; std::endl; // outputs "abcd"
    std::cout &lt;&lt; B::st &lt;&lt; std::endl; // outputs "abcd"
}
</code></pre>