[patch, fortran] Check bounds for matrix-vector multiplication

Steve Kargl sgk@troutmask.apl.washington.edu
Mon May 1 16:40:00 GMT 2017


On Mon, May 01, 2017 at 06:19:28PM +0200, Thomas Koenig wrote:

> +	if (m_case == A2B2)
> +	  {
> +	    a2 = get_array_inq_function (GFC_ISYM_SIZE, matrix_a, 2);
> +	    b1 = get_array_inq_function (GFC_ISYM_SIZE, matrix_b, 1);
> +	    test = runtime_error_ne (b1, a2, "Dimension of array B incorrect "
> +				     "in MATMUL intrinsic: Is %ld, should be %ld");
> +	    *next_code_point = test;
> +	    next_code_point = &test->next;
> +	  }
> +	else if (m_case == A2B1)
> +	  {
> +	    a2 = get_array_inq_function (GFC_ISYM_SIZE, matrix_a, 2);
> +	    b1 = get_array_inq_function (GFC_ISYM_SIZE, matrix_b, 1);
> +	    test = runtime_error_ne (b1, a2, "Dimension of array B incorrect "
>  				   "in MATMUL intrinsic: Is %ld, should be %ld");
> -	  *next_code_point = test;
> -	  next_code_point = &test->next;
> +	    *next_code_point = test;
> +	    next_code_point = &test->next;
> +	  }
>  	}

Why the duplicate code?  Seems like an OR is needed.

	if (m_case == A2B1 || m_case == A2B2)
	  {
	    a2 = get_array_inq_function (GFC_ISYM_SIZE, matrix_a, 2);
	    b1 = get_array_inq_function (GFC_ISYM_SIZE, matrix_b, 1);
	    test = runtime_error_ne (b1, a2, "Dimension of array B incorrect "
				     "in MATMUL intrinsic: Is %ld, should be %ld");
	    *next_code_point = test;
	    next_code_point = &test->next;
	  }

-- 
Steve
20170425 https://www.youtube.com/watch?v=VWUpyCsUKR4
20161221 https://www.youtube.com/watch?v=IbCHE-hONow



More information about the Fortran mailing list