[cfe-commits] r140621 - /cfe/trunk/www/compatibility.html
Douglas Gregor
dgregor at apple.com
Tue Sep 27 11:58:27 PDT 2011
Author: dgregor
Date: Tue Sep 27 13:58:27 2011
New Revision: 140621
URL: http://llvm.org/viewvc/llvm-project?rev=140621&view=rev
Log:
Document the incompatibility that stems from Clang properly implement
the rule that defines the implicit copy constructor/implicit copy
asssignment operator as deleted when a move constructor or move
assignment operator has been explicitly declared. This has hit a
number of people because Boost 1.47.0's shared_ptr fails to declare a
copy constructor.
Modified:
cfe/trunk/www/compatibility.html
Modified: cfe/trunk/www/compatibility.html
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/compatibility.html?rev=140621&r1=140620&r2=140621&view=diff
==============================================================================
--- cfe/trunk/www/compatibility.html (original)
+++ cfe/trunk/www/compatibility.html Tue Sep 27 13:58:27 2011
@@ -60,6 +60,12 @@
<li><a href="#param_name_lookup">Parameter name lookup</a></li>
</ul>
</li>
+ <li><a href="#c++11">C++11 compatibility</a>
+ <ul>
+ <li><a href="#deleted-special-func">Deleted special member
+ functions</a></li>
+ </ul>
+ </li>
<li><a href="#objective-c++">Objective-C++ compatibility</a>
<ul>
<li><a href="#implicit-downcasts">Implicit downcasts</a></li>
@@ -755,7 +761,39 @@
<p>Clang diagnoses this error (where the parameter name has been redeclared). To fix this problem, rename one of the parameters.</p>
<!-- ======================================================================= -->
-<h2 id="objective-c++">Objective-C++ compatibility</h3>
+<h2 id="c++11">C++11 compatibility</h2>
+<!-- ======================================================================= -->
+
+<!-- ======================================================================= -->
+<h3 id="deleted-special-func">Deleted special member functions</h3>
+<!-- ======================================================================= -->
+
+<p>In C++11, the explicit declaration of a move constructor or a move
+assignment operator within a class disables the implicit declaration
+of the copy constructor and copy assignment operator. This change came
+fairly late in the C++11 standardization process, so early
+implementations of C++11 (including Clang before 3.0, GCC before 4.7,
+and Visual Studio 2010) do not implement this rule, leading them to
+accept this ill-formed code:</p>
+
+<pre>
+struct X {
+ X(X&&); <i>// suppresses implicit copy constructor</i>
+};
+
+void f(X x);
+void g(X x) {
+ f(x); <i>// error: X has no copy constructor</i>
+}
+</pre>
+
+<p>This affects some C++11 code, including Boost's popular <a
+href="http://www.boost.org/doc/libs/release/libs/smart_ptr/shared_ptr.htm"><tt>shared_ptr</tt></a>
+up to version 1.47.0. The fix for Boost's <tt>shared_ptr</tt> is
+<a href="https://svn.boost.org/trac/boost/changeset/73202">available here</a>.</p>
+
+<!-- ======================================================================= -->
+<h2 id="objective-c++">Objective-C++ compatibility</h2>
<!-- ======================================================================= -->
<!-- ======================================================================= -->
More information about the cfe-commits
mailing list