I found a couple of build failures in Fedora packages due to stinky
code like:

 if (file != NULL)

This fails due to the removal of basic_ios::operator void*() in C++11,
which is already documented on the porting_to page, but the symptoms
are sufficiently different to deserve documenting.

Committed to CVS.


Index: htdocs/gcc-6/porting_to.html
===================================================================
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-6/porting_to.html,v
retrieving revision 1.22
diff -u -r1.22 porting_to.html
--- htdocs/gcc-6/porting_to.html	12 Apr 2016 04:46:19 -0000	1.22
+++ htdocs/gcc-6/porting_to.html	23 May 2016 14:22:37 -0000
@@ -111,6 +111,21 @@
 <code>return static_cast&lt;bool&gt;(os);</code>
 </p>
 
+<h4 id="iostream-comparisons">No match for 'operator!=' (operand types are 'std::ifstream' and 'int')</h4>
+
+<p>
+The change to iostream classes also affects code that tries to check for stream
+errors by comparing to <code>NULL</code> or <code>0</code>.
+Such code should be changed to simply test the stream directly, instead of
+comparing it to a null pointer:
+</p>
+
+<pre><code>
+  if (file) {   // not if (file != NULL), or if (file != 0)
+    ...
+  }
+</code></pre>
+
 <h4 id="complex-lvalues">Lvalue required as left operand of assignment with complex numbers</h4>
 
 <p>

Reply via email to