public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Gabriel Dos Reis <gdr@integrable-solutions.net>
To: Oleg Endo <oleg.endo@t-online.de>
Cc: Jason Merrill <jason@redhat.com>,
	Andrew Sutton <andrew.n.sutton@gmail.com>,
	gcc-patches@gcc.gnu.org, 	Benjamin Kosnik <bkoz@redhat.com>,
	Lawrence Crowl <crowl@google.com>,
	Diego Novillo <dnovillo@google.com>
Subject: Re: [c++-concepts] code review
Date: Mon, 10 Jun 2013 00:34:00 -0000	[thread overview]
Message-ID: <CAAiZkiCsA8jxMufRnmoUYOT5BbUDfPzX2NKJkrh-bywkobnmng@mail.gmail.com> (raw)
In-Reply-To: <1370810089.2365.5.camel@yam-132-YW-E178-FTW>

On Sun, Jun 9, 2013 at 3:34 PM, Oleg Endo <oleg.endo@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	other threads:[~2013-06-10  0:34 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-28 14:07 [c++-concepts] Reserving new keywords for concepts Andrew Sutton
2013-02-28 14:51 ` Gabriel Dos Reis
2013-02-28 15:01   ` Andrew Sutton
2013-02-28 15:11     ` Gabriel Dos Reis
2013-02-28 15:54       ` Andrew Sutton
2013-02-28 15:57         ` Gabriel Dos Reis
2013-06-06 15:55   ` [c++-concepts] code review Jason Merrill
2013-06-06 17:48     ` Andrew Sutton
2013-06-06 20:29       ` Jason Merrill
2013-06-08 13:35         ` Andrew Sutton
2013-06-10  0:49           ` Gabriel Dos Reis
2013-06-10 16:27             ` Jason Merrill
2013-06-10 19:30           ` Jason Merrill
2013-06-11 13:45             ` Andrew Sutton
2013-06-11 14:27               ` Jason Merrill
2013-06-11 14:49                 ` Andrew Sutton
2013-06-11 15:00                   ` Jason Merrill
2013-06-11 15:09                     ` Andrew Sutton
2013-06-11 17:54                       ` Jason Merrill
2013-06-12 15:53             ` Gabriel Dos Reis
2013-06-12 16:35               ` Jason Merrill
2013-06-14 15:32                 ` Andrew Sutton
2013-06-15  1:40                   ` Jason Merrill
2013-06-15  2:13                     ` Gabriel Dos Reis
2013-06-17 18:11                     ` Andrew Sutton
2013-06-17 19:20                       ` Jason Merrill
2013-06-18  0:29                         ` Gabriel Dos Reis
2013-06-18 16:28                         ` Andrew Sutton
2013-06-19 14:21                           ` Jason Merrill
2013-06-19 16:10                             ` Andrew Sutton
2013-06-20  5:30                             ` Gabriel Dos Reis
2013-06-20 13:01                               ` Jason Merrill
2013-06-20 13:09                                 ` Gabriel Dos Reis
2013-06-20 13:19                                   ` Andrew Sutton
2013-06-20 13:57                                     ` Jason Merrill
2013-06-20 14:18                                       ` Andrew Sutton
2013-06-20 15:17                                         ` Jason Merrill
2013-06-20 15:22                                           ` Gabriel Dos Reis
2013-06-20 15:27                                             ` Jason Merrill
2013-06-20 15:29                                               ` Gabriel Dos Reis
2013-06-20 15:50                                           ` Andrew Sutton
2013-06-20 17:23                                             ` Jason Merrill
2013-06-20 18:33                                               ` Jason Merrill
2013-06-21 12:46                                                 ` Andrew Sutton
2013-06-24 15:55                                                   ` Jason Merrill
2013-06-20 15:20                                     ` Gabriel Dos Reis
2013-06-09 20:34         ` Oleg Endo
2013-06-10  0:34           ` Gabriel Dos Reis [this message]
2013-06-10 14:51             ` Diego Novillo
2013-06-10 22:51               ` Lawrence Crowl
2013-06-10 16:14             ` Jason Merrill
2015-05-01 18:32 Jason Merrill
2015-05-01 19:21 ` Andrew Sutton
2015-05-08 20:08 ` Andrew Sutton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAAiZkiCsA8jxMufRnmoUYOT5BbUDfPzX2NKJkrh-bywkobnmng@mail.gmail.com \
    --to=gdr@integrable-solutions.net \
    --cc=andrew.n.sutton@gmail.com \
    --cc=bkoz@redhat.com \
    --cc=crowl@google.com \
    --cc=dnovillo@google.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=oleg.endo@t-online.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).