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 fortran/34396] Length of substrings defined by expressions not correctly computed in constructors



------- Comment #6 from pault at gcc dot gnu dot org  2007-12-09 17:14 -------
Dominique,

> Yes it depends of the memory content, anyway the 0 in your results should be
> spaces.
> 

Ah yes.  The problem is in trans-array.c(gfc_trans_array_ctor_element), where  
the assignment, line 975 onwards, uses memcpy and produces this code:

    {
      integer(kind=4) D.879;
      integer(kind=4) len.6;
      character(kind=1) * pstr.5;

      _gfortran_string_trim (&len.6, (void * *) &pstr.5, 5, &y[1]{lb: 1 sz:
1});
      D.879 = len.6;
      if (len.6 > 0)
        {
          {
            void * D.878;

            D.878 = (void *) pstr.5;
            if (D.878 != 0B)
              {
                __builtin_free (D.878);
              }
          }
        }
      __builtin_memcpy (&(*(character(kind=1)[0:][1:5] *)
atmp.2.data)[0][1]{lb: 1 sz: 1}, &y[1]{lb: 1 sz: 1}, MAX_EXPR <NON_LVALUE_EXPR
<D.879>, 0>);
    }

This is called in two places and the returned se->string_length could be used
for bounds checking.  Also, the required padding with spaces could be done too.
 ss->string_length has the length of the target.

I am setting aside evenings of this week to a determined attack on PRs 31213,
33888 and 33998.  I have solutions to most of the bugs and it now needs
packaging up and submitting. If this PR still remains next week, I'll give it a
try.  Otherwise, I would be happy to lend a helping hand...

Cheers

Paul


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34396


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