This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/51749] Including <algorithm> pollute global namespace


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]