Some notes for /gcc-9/porting_to.html (I haven't seen this change cause any issues in practice, but it doesn't hurt to document it).
Committed to CVS.
Index: htdocs/gcc-9/porting_to.html =================================================================== RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-9/porting_to.html,v retrieving revision 1.4 diff -u -r1.4 porting_to.html --- htdocs/gcc-9/porting_to.html 17 Apr 2019 18:32:41 -0000 1.4 +++ htdocs/gcc-9/porting_to.html 13 May 2019 11:55:25 -0000 @@ -111,9 +111,51 @@ } </code></pre> -<!-- <h2 id="cxx">C++ language issues</h2> ---> + +<h3> + <code>operator new(size_t, nothrow_t)</code> calls + <code>operator new(size_t)</code> +</h3> + +<p> +GCC 9 implements the requirement introduced in the C++ 2011 standard that +the <code>nothrow</code> version of <code>operator new</code> calls the +ordinary, throwing version of <code>operator new</code> (and catches any +exception and instead returns a null pointer). +This was changed by <a href="https://wg21.link/lwg206">DR 206</a> to ensure +that the various forms of <code>operator new</code> do not become decoupled +if a user only replaces the ordinary <code>operator new</code>. +</p> + +<p> +Code that only replaces one version of <code>operator new</code> and expects +the other versions to be unaffected might change behaviour when using GCC 9. +</p> + +<p> +If your program uses a replacement <code>operator new(size_t, nothrow_t)</code> +then it must also replace <code>operator new(size_t)</code> and +<code>operator delete(void*)</code>, and ensure memory obtained from the +<code>nothrow</code> version of <code>new</code> can be freed by the ordinary +version of <code>operator delete</code>. +</p> + +<p> +The simplest solution is to only replace the ordinary +<code>operator new(size_t)</code> and +<code>operator delete(void*)</code> +functions, and the replaced versions will be used by all of +<code>operator new(size_t, nothrow_t)</code>, +<code>operator new[](size_t)</code> and +<code>operator new[](size_t, nothrow_t)</code> +and the corresponding <code>operator delete</code> functions. +To support types with extended alignment you may also need to replace +<code>operator new(size_t, std::align_val_t)</code> and +<code>operator delete(void*, std::align_val_t)</code> +(which will then be used by the <code>nothrow</code> and array forms for +extended alignments). +</p> <!-- <h2 id="fortran">Fortran language issues</h2>