[libgfortran,patch] Zero-length strings messed up in library (PR33079)

Tobias Burnus burnus@net-b.de
Thu Aug 16 14:56:00 GMT 2007


Tobias Schlüter wrote:
> Tobias Schlüter wrote:
>> An alternative would be to have a
>>  static char zero_length_string[0]; // Maybe [1]
>> at file scope and then do
>>  *dest = zero_length_string;
>> This would evade the unnecessary allocations.
> Or the even shorter:
>   static char zero_length_string;
>   *dest = &zero_length_string;
Indeed this would be a good option as we currently do not deallocate
that variable if len == 0.


    _gfortran_string_trim (&len.2, (void * *) &pstr.1, 1, &s[1]{lb: 1
sz: 1});
    bar (pstr.1, len.2);
    if (len.2 > 0)
      {
        {
          void * D.1379;

          D.1379 = (void *) pstr.1;
          if (D.1379 != 0B)
            {
              __builtin_free (D.1379);
            }

Tobias



More information about the Gcc-patches mailing list