public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "paolo.carlini at oracle dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/51749] Including <algorithm> pollute global namespace
Date: Wed, 04 Jan 2012 10:26:00 -0000	[thread overview]
Message-ID: <bug-51749-4-a6jk0ilnZv@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-51749-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51749

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-01-04 10:25:45 UTC ---
Thus I understand you are new to GCC, because the problem was already there in,
eg, gcc3, and very likely the original HP/SGI STL! It's because of the use of
rand(), or a similar system function, which requires including <cstdlib>. Note,
all of this is in general allowed by the standard: including a <c*> header as
an implementation detail, and <cstdlib> specifically including <stdlib.h> as an
implementation detail. The latter unfortunately on these particular systems
also provides 'set'.

In principle we could handle this specific manifestation of the annoyance by
eg, adding to the compiler a __builtin_rand, but it's too late for 4.7, or by
exporting from the .so some __rand function. The latter idea doesn't sound too
bad to me, wasn't done in the original HP/SGI code because it didn't come with
any .src files.

Anyway, beware that many more of these issues are lurking around, we don't
control the underlying libc and the stuff its headers provide in the global
namespace, sooner or later you may find unexpected names in it.


  parent reply	other threads:[~2012-01-04 10:26 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-04  9:52 [Bug libstdc++/51749] New: " nospam.kotarou.dono at gmail dot com
2012-01-04 10:17 ` [Bug libstdc++/51749] " rguenth at gcc dot gnu.org
2012-01-04 10:26 ` paolo.carlini at oracle dot com [this message]
2012-01-07  4:14 ` nospam.kotarou.dono at gmail dot com
2012-01-07  8:10 ` jakub at gcc dot gnu.org
2012-01-08 12:15 ` nospam.kotarou.dono at gmail dot com
2012-01-08 12:41 ` redi at gcc dot gnu.org
2012-01-17  8:47 ` [Bug libobjc/51749] " nospam.kotarou.dono at gmail dot com
2012-01-17 11:06 ` [Bug libstdc++/51749] " paolo.carlini at oracle dot com
2012-01-17 12:01 ` [Bug libstdc++/51749] Including <algorithm> pollutes " redi at gcc dot gnu.org
2012-01-17 12:16 ` [Bug libobjc/51749] " nospam.kotarou.dono at gmail dot com
2012-01-17 12:54 ` [Bug libstdc++/51749] " redi at gcc dot gnu.org
2012-01-17 12:56 ` nospam.kotarou.dono at gmail dot com
2012-01-17 13:05 ` redi at gcc dot gnu.org
2012-01-29 10:39 ` nospam.kotarou.dono at gmail dot com
2012-01-29 11:33 ` paolo.carlini at oracle dot com
2013-06-11  8:59 ` paolo.carlini at oracle dot com
2013-06-11  9:39 ` nmm1 at cam dot ac.uk
2013-06-11  9:44 ` redi at gcc dot gnu.org
2013-06-11  9:51 ` jakub at gcc dot gnu.org
2013-06-11  9:54 ` redi at gcc dot gnu.org
2013-06-11 10:05 ` jakub at gcc dot gnu.org
2013-06-11 10:10 ` paolo.carlini at oracle dot com
2013-06-11 10:21 ` jakub at gcc dot gnu.org
2013-06-11 10:24 ` redi at gcc dot gnu.org
2013-06-11 11:08 ` nmm1 at cam dot ac.uk
2013-06-11 11:21 ` jakub at gcc dot gnu.org
2014-01-26  0:06 ` redi at gcc dot gnu.org
2014-01-26 10:19 ` redi at gcc dot gnu.org
2014-01-26 17:24 ` joseph at codesourcery dot com
2014-01-26 22:50 ` redi at gcc dot gnu.org
2021-04-19 10:40 ` redi at gcc dot gnu.org

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=bug-51749-4-a6jk0ilnZv@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).