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


On 12/16/2016 06:31 PM, Janus Weil wrote:
> 2016-12-16 18:53 GMT+01:00 Pedro Alves <palves@redhat.com>:
>> On 12/16/2016 05:33 PM, Janus Weil wrote:

>>> And in particular: How do the current uses of
>>> std::string in GCC deal with this problem? (Do they?)
>>
>> Doesn't look like they do.
> 
> Huh, that's a problem then, isn't it?

Right.  The easiest way to trigger it I think is if something
computes some size incorrectly, and calls for example string::reserve(-1)
or string::resize(-1) by mistake (likewise for std::vector, etc.).
malloc will fail, new will throw bad_alloc, and GCC will abort and
maybe generate a core dump, instead of gracefully printing
something like:

   cc1: out of memory allocating NNNNNNNN bytes ...

and existing with error status.

Thanks,
Pedro Alves


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