On Sun, Jun 9, 2013 at 3:34 PM, Oleg Endo <oleg.e...@t-online.de> wrote:
> On Thu, 2013-06-06 at 16:29 -0400, Jason Merrill wrote:
>> On 06/06/2013 01:47 PM, Andrew Sutton wrote:
>> > I never did understand why this happens. Compiling with GCC-4.6, I get
>> > these errors originating in logic.cc from an include of <algorithm>.
>> > This is what I get:
>> >
>> > /usr/include/c++/4.6/cstdlib:76:8: error: attempt to use poisoned "calloc"
>>
>> Ah, I see: adding the include gets the mentions of malloc in before the
>> names are poisoned.  This change is OK.
>>
>
> I ran into the same issue when I started using C++ std:: stuff in the SH
> backend code last year.  I posted a patch, but somehow it didn't go
> anywhere...
>
> http://gcc.gnu.org/ml/gcc-patches/2012-09/msg00880.html
>
> The workaround was to include <cstdlib> as the first include in sh.c.
> Would it be possible to have the change above also in trunk?
>
> Cheers,
> Oleg
>

I strongly suggest prefering <stdlib.h> over <cstdlib> for GCC source code
base.  The reason is that it brings us very little:
    1. Not all compilers implement C++93/C++03 semantics on all platforms;
      in fact even GCC didn't on solaris platforms for example.  So, from
       bootstrapping purposes, we better be on the safer side.

    2. C++11 says that  the implementation is free to define names in
      both namespaces (global and std.)  If we ever accept C++11 in
      5-10 years, we better have something can withstand the evolution.

So, my advice is for GCC source code to forget about the <cxxx>
headers for the  most part.  I can see an instance where <cmath> or <cstring>
would make a difference but given point (1) above, no it doesn't.
Just use the traditional <xxx.h> headers and be done with it.

Maybe I should have included this in our C++ coding standards, but
I don't know how Benjamin, Lawrence, and Diego fee about it.

-- Gaby

Reply via email to