summaryrefslogtreecommitdiff
path: root/www
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-06-02 01:26:32 +0000
committerJohn McCall <rjmccall@apple.com>2010-06-02 01:26:32 +0000
commit4a40a2f8202e624f32736caf5eec7ad10b4c07fa (patch)
tree8200a932ee4674e0da126b21c4c1ab08dff4bd6c /www
parent79ed4e6ae5edeffbed3b54d2957575ab7ede3dc9 (diff)
downloadclang-4a40a2f8202e624f32736caf5eec7ad10b4c07fa.tar.gz
Add a compatibility note about incomplete types in templates.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105309 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'www')
-rw-r--r--www/cxx_compatibility.html32
1 files changed, 32 insertions, 0 deletions
diff --git a/www/cxx_compatibility.html b/www/cxx_compatibility.html
index fe032403d7..02dabbe8e3 100644
--- a/www/cxx_compatibility.html
+++ b/www/cxx_compatibility.html
@@ -25,6 +25,7 @@
<li><a href="#init_static_const">Initialization of non-integral static const data members within a class definition</a></li>
<li><a href="#dep_lookup">Unqualified lookup in templates</a></li>
<li><a href="#dep_lookup_bases">Unqualified lookup into dependent bases of class templates</a></li>
+<li><a href="#undep_incomplete">Incomplete types in templates</a></li>
<li><a href="#bad_templates">Templates with no valid instantiations</a></li>
<li><a href="#default_init_const">Default initialization of const variable of a class type requires user-defined default constructor</a></li>
</ul>
@@ -215,6 +216,37 @@ if <tt>DoThis</tt> is virtual, calling it this way will bypass virtual
dispatch!
<!-- ======================================================================= -->
+<h2 id="undep_incomplete">Incomplete types in templates</h2>
+<!-- ======================================================================= -->
+
+The following code is invalid, but compilers are allowed to accept it:
+
+<pre>
+ class IOOptions;
+ template &lt;class T&gt; bool read(T &amp;value) {
+ IOOptions opts;
+ return read(opts, value);
+ }
+
+ class IOOptions { bool ForceReads; };
+ bool read(const IOOptions &amp;opts, int &amp;x);
+ template bool read&lt;&gt;(int &amp;);
+</pre>
+
+The standard says that types which don't depend on template parameters
+must be complete when a template is defined if they affect the
+program's behavior. However, the standard also says that compilers
+are free to not enforce this rule. Most compilers enforce it to some
+extent; for example, it would be an error in GCC to
+write <tt>opts.ForceReads</tt> in the code above. In Clang, we feel
+that enforcing the rule consistently lets us provide a better
+experience, but unfortunately it also means we reject some code that
+other compilers accept.
+
+<p>We've explained the rule here in very imprecise terms; see
+[temp.res]p8 for details.
+
+<!-- ======================================================================= -->
<h2 id="bad_templates">Templates with no valid instantiations</h2>
<!-- ======================================================================= -->