https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67779

--- Comment #13 from Paul Thomas <pault at gcc dot gnu.org> ---
(In reply to Thomas Koenig from comment #11)
> Created attachment 37182 [details]
> More simplified test case
> 
> This illustrates the problem - the array is passed wrong on
> the first call to the subroutine.
> 
> Output:
> 
>  array on input
>     5     1     4     3     2  
>  array on input
>     1     4     3     2  
>  array on input
>     1     4     3  
>  array on input
>     1     4  
>  array on input
>     1

The call to quicksort from the main program generates:
    class.15._vptr = (struct __vtype_myclass_def_Myclass * {ref-all})
&__vtab_myclass_def_Mysortable;
    parm.16.dtype = 297;
    parm.16.dim[0].lbound = 1;
    parm.16.dim[0].ubound = 5;
    parm.16.dim[0].stride = 1;
    parm.16.data = (void *) &array[0];
    parm.16.offset = -1;
    class.15._data = parm.16;
    quicksort (&class.15);

whereas the recursive call to self is:
      parm.11.dim[0].lbound = 1;
      parm.11.dim[0].ubound = D.3501;
      parm.11.dim[0].stride = NON_LVALUE_EXPR <D.3503>;
      parm.11.data = NON_LVALUE_EXPR <array->_data.data>;
      parm.11.offset = 0;
      class.12._data = VIEW_CONVERT_EXPR<struct array1_myclass>(parm.11);
      class.12._vptr = array->_vptr;
      quicksort (&class.12);

It is the offset being set to zero, rather than -1, that does the damage.

Paul

Reply via email to