varargs and conversion operators in MFC CString
<p>In MFC under all versions of Visual C++ that I've tested, the following code compiles and works;</p>

<pre><code>CString A = "String A", B;
B.Format("The value of A is %s", A);
</code></pre>

<p>but produces the warning</p>

<pre class="lang-none prettyprint-override"><code>C6284, Object passed as _Param_(2) when a string is required in call to 
'ATL::CStringT&lt;char,StrTraitMFC&lt;char,ATL::ChTraitsCRT&lt;char&gt; &gt; &gt;::Format'
 Actual type: 'class ATL::CStringT&lt;char,class StrTraitMFC&lt;char,class ATL::ChTraitsCRT&lt;char&gt; &gt; &gt;'.
</code></pre>

<p>Looking at the source to CString and its ancestory of CStringT, CSimpleStrT, while there is a conversion operator to effectively convert to a char* as shown below;</p>

<pre><code>operator PCXSTR() const throw()
{
    return( m_pszData );
}
</code></pre>

<p>it also appears that the data buffer is the first data element in the class, and tracing through the execution under the debugger suggests the conversion operator is not called, and the code works purely on the basis of class layout.</p>

<p>While the original code could be easily rewritten to avoid the above, is it necessary and likely to get broken by a future MFC update?  The part of the code base involved is largely 3rd party and I'd rather avoid changing it without good reason.</p>