This is the mail archive of the gcc-patches@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: [libgfortran,patch] Zero-length strings messed up in library (PR33079)


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


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