[EXT_EP-11172] Compiler fails with internal error "Bad kind: TYPE::type_pointed_to" Created: 19/Jun/23  Updated: 14/Apr/25  Resolved: 15/Sep/23

Status: Fixed
Project: Embedded Software & Tools
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Medium
Reporter: TI User Assignee: TI User
Resolution: Fixed Votes: 0
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Product: Code Generation Tools
Internal ID: CODEGEN-11223
Forum URL: https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1238750/tms320f28388d-optimization-problems-compiler
Found In Release: C2000_22.6.0.LTS
C6000_8.3.0
MSP430_20.2.0.LTS
C7000_2.1.0.LTS
MSP430_21.6.0.LTS
C2000_21.6.0.LTS
PRU_2.3.0
C7000_3.1.0.LTS
ARM_20.2.0.LTS
Fix In Release: C2000_25.3.0.LTS*
C7000_2.1.3.LTS*
MSP430_21.6.2.LTS*
C2000_22.6.1.LTS
C7000_4.1.0.LTS
C2000_21.6.2.LTS*
MSP430_20.2.8.LTS*
C7000_3.1.1.LTS
C6000_8.3.13
ARM_20.2.8.LTS*
PRU_2.4.0*
PRU_2.3.4*
Affected Platform/Device: default
Workaround: use --opt_level=0 or 1 instead of 2

 Description   

NOTE: CODEGEN-11634 addresses another use case that below fix did not.

With --opt_level=2, the optimizer generates "internal error" for arrays of pointers similar to below example:
TP>> internal error: Bad kind: TYPE::type_pointed_to
void foo(void)

{ char* argv[1]; parse_args(argv); }

More details:
----------------
The attached file has these lines ...

static inline __erase_vector __parse_args(uint8_t* ptrInput, uint8_t* argv[])
{
    /* code here */
}

Build it ...

% cl2000 -@options.txt file.c
"file.c", line 2639: warning #303-D: typedef name has already been declared (with same type)
"file.c", line 2640: warning #303-D: typedef name has already been declared (with same type)
"file.c", line 2679: warning #303-D: typedef name has already been declared (with same type)
TP>> internal error: Bad kind:  TYPE::type_pointed_to
This is caused by a defect in the TI C/C++ Optimizer.
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.

Contact TI in the E2E support forums at http://e2e.ti.com under
"Development Tools", "TI C/C++ Compiler".  See the link titled
"Submitting an issue".

We need to see this ENTIRE error message and a complete, reproducible
test case including ALL of the command-line options.
Include the .pp file created by option --preproc_with_comment


>> Compilation failure

Replace that function with an extern declaration ...

extern __erase_vector __parse_args(uint8_t* ptrInput, uint8_t* argv[]);

... and it builds clean.


Generated at Mon Jul 28 19:18:28 CDT 2025 using Jira 10.3.7#10030007-sha1:a563685562f94d165eb4e158cfb2a142338d8c54.