diff mbox

PATCH to add include <cstdlib> from system.h

Message ID 1371902594.3742.34.camel@yam-132-YW-E178-FTW
State New
Headers show

Commit Message

Oleg Endo June 22, 2013, 12:03 p.m. UTC
On Thu, 2013-06-20 at 15:21 -0400, Jason Merrill wrote:
> Since we poison "malloc" and friends in system.h, any C++ code that 
> includes a standard library header such as <algorithm>, which in turn 
> includes <cstdlib>, will get poisoning errors due to lines like
> 
> > #undef malloc
> >   using ::malloc;
> 
> The solution is to include <cstdlib> before poisoning those identifiers.
> 
> Oleg posted a variant of this patch last year, which included <cstdlib> 
> instead of <stdlib.h>; my patch includes both to avoid issues with other 
> library implementations in which <cstdlib> might not declare functions 
> in the global namespace.
> 
> Tested x86_64-pc-linux-gnu, applying to trunk.

Cool, thanks!
I've committed the attached patch as rev 200328, which removes the
<cstdlib> workaround in the SH backend.

Cheers,
Oleg


gcc/ChangeLog:

	* config/sh/sh.c: Remove <cstdlib> workaround.
diff mbox

Patch

Index: gcc/config/sh/sh.c
===================================================================
--- gcc/config/sh/sh.c	(revision 200327)
+++ gcc/config/sh/sh.c	(working copy)
@@ -19,12 +19,6 @@ 
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-/* FIXME: This is a temporary hack, so that we can include <algorithm>
-   below.  <algorithm> will try to include <cstdlib> which will reference
-   malloc & co, which are poisoned by "system.h".  The proper solution is
-   to include <cstdlib> in "system.h" instead of <stdlib.h>.  */
-#include <cstdlib>
-
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"