This is the mail archive of the gcc@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]

Re: using C++ STL containers in GCC/gfortran source code


Hi Nick,

2016-12-16 18:16 GMT+01:00 N.M. Maclaren <nmm1@cam.ac.uk>:
> On Dec 16 2016, Janus Weil wrote:
>>
>> What I'd like to know is: In the current state of things in GCC, is it
>> possible/reasonable to use any of the STL containers (like
>> std::vector, std::string, whatever) in GCC and its front ends (in
>> particular gfortran)?
>>
>> That question has two parts:
>> 1) Is it technically possible at all? Are there drawbacks/pitfalls?
>> (In particular Jakub mentioned possible memory management issues, i.e.
>> xmalloc vs malloc etc.)
>
>
> I can say something about this, which is not gcc-specific.  The executive
> summary is that there shouldn't be any problem if you KISS, but heaven
> help you if you don't.

thanks for this lengthy comment, but that's really not the kind of
discussion I wanna get into here. (And I don't actually agree to all
of your points, but that doesn't matter.)

What I want to discuss is deeply GCC-specific, the central point
being: If I use some STL container in one of the front ends (like
gfortran), does that mess with GCC's idea of memory management? To
quote Jakub from PR 78822, commenting on my proposal to use
std::string in gfortran:

"You would need to make sure it uses a xmalloc based allocator first
or at least calls xmalloc_failed upon allocation failure, otherwise it
will be a serious regression."

I'm really not an expert on GCC's memory management principles and how
it uses xmalloc over malloc. I'd love to hear further comments on the
above sentence (e.g. whether that is really necessary, and if yes, how
to accomplish it). And in particular: How do the current uses of
std::string in GCC deal with this problem? (Do they?)

Cheers,
Janus


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