This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software: TI C/C++ Compiler
The code snippet:
void test_signed_unsigned_type_mismatch( const double * restrict f32, unsigned int * restrict i16, int num )
{
for ( ; num > 0; num-- )
{
*i16++ = __f32toi16r( *f32++ );
}
}
compiled with the command:
"C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_16.9.3.LTS/bin/cl2000" -v28 -ml -mt --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 -O4 --opt_for_speed=5 --fp_mode=relaxed --include_path="C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_16.9.3.LTS/include" --advice:performance=all --define=_INLINE -g --c99 --diag_warning=225 --diag_wrap=off --display_error_number --gen_func_subsections=on --sat_reassoc=on --asm_listing --src_interlist --gen_func_info_listing --gen_opt_info=1 --gen_preprocessor_listing --section_sizes=on --preproc_with_compile --preproc_dependency="f32toi16r.d" "../f32toi16r.c"
gives the error:
error #99923: "../f32toi16r.c", line 5: Illegal use of intrinsic: __f32toi16r
The code snippet:
void test_signed_unsigned_type_mismatch( const double * restrict f32, int * restrict i16, int num )
{
for ( ; num > 0; num-- )
{
*i16++ = __f32toui16r( *f32++ );
}
}
compiled with the command:
"C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_16.9.3.LTS/bin/cl2000" -v28 -ml -mt --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 -O4 --opt_for_speed=5 --fp_mode=relaxed --include_path="C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_16.9.3.LTS/include" --advice:performance=all --define=_INLINE -g --c99 --diag_warning=225 --diag_wrap=off --display_error_number --gen_func_subsections=on --sat_reassoc=on --asm_listing --src_interlist --gen_func_info_listing --gen_opt_info=1 --gen_preprocessor_listing --section_sizes=on --preproc_with_compile --preproc_dependency="f32toi16r.d" "../f32toi16r.c"
gives the error:
error #99923: "../f32toi16r.c", line 5: Illegal use of intrinsic: __f32toui16r
The code snippets:
void test_no_sign_mismatch( const double * restrict f32, unsigned int * restrict i16, int num )
{
for ( ; num > 0; num-- )
{
*i16++ = __f32toui16r( *f32++ );
}
}
and:
void test_no_sign_mismatch( const double * restrict f32, int * restrict i16, int num )
{
for ( ; num > 0; num-- )
{
*i16++ = __f32toi16r( *f32++ );
}
}
successfully compile.
For signed to unsigned the result is specified in the C standard as the result modulo 65536. For the unsigned to signed it is defined if the number unsigned number is in the signed range and implementation defined if the unsigned number is out of the integer range.
Why does a return type and assignment type mismatch cause a compiler error?
In my opinion, it should not cause an error. I consider this a bug, and have submitted CODEGEN-3580 to track this issue.
Btw the posts http://e2e.ti.com/support/microcontrollers/c2000/f/171/t/243787 and http://e2e.ti.com/support/development_tools/compiler/f/343/t/261146, both from early 2013, are about the same problem, so those posts can probably be closed / redirected here.
I don't think those are the same problem. In both of those cases, the value of the intrinsic is assigned to a type with the same sign. CODEGEN-3580 requires the value of the intrinsic to be assigned to a type with the opposite sign.