CCSTUDIO: Problem when declaring a temporary array as argument of a function call placed inside a compund statement

Part Number: CCSTUDIO

Hello,

I would like to report a problem with the example code below.

#include <stdint.h>
#include <stdlib.h>

static uint16_t do_something_with_array(uint16_t * const array_ptr, size_t num_array_entries);

int main(void)
{
	if (
		({
			uint16_t my_array[5]= {1,2,3,4,5};

			//(do_something_with_array(my_array, 5) != 5);
			(do_something_with_array((uint16_t[]){1,2,3,4,5}, 5) != 5);
		})
		)
	{
		// return with error.
		return 1;
	}

	if (do_something_with_array((uint16_t[]){1,2,3,4,5}, 5) != 5)
	{
		return 1;
	}

	return 0;
}

static uint16_t do_something_with_array(uint16_t * const array_ptr, size_t num_array_entries)
{
	return 0;
}

If the code is compiled as is, the C2000 compiler (v25.11.0LTS) issues the following error message:

"INTERNAL ERROR: C:\ti\ccs1250\ccs\tools\compiler\ti-cgt-c2000_25.11.0.LTS\bin\acia2000.exe experienced a segmentation fault while processing function main file ../main2.c line 27
 
This is caused by a defect in the TI EABI C/C++ Parser.
TI Customer Support may be able to suggest a workaround to avoid this.
 
Upgrading to the newest version of the compiler may fix this problem."

The error disappears if the commented function call inside the compound statement is uncommented and the successive line is commented.

Please note that the function call causing the problem is also repeated later but outside of any compound statement, and it does not cause any trouble.

So the problem occurs when an array is declared as part of an argument of a function call placed inside a compound statement.

You can easily reproduce the problem by simply copying and pasting the above code into the main.c source file of a new project whose compiler is configured for relaxed parsing.

Thank you for your attention,

Best Regards,

Alberto Gaeta