04-01: 关于IAR报错:
Tool Internal Error:Internal Error: [assign_colors_C01]: Cannot coalesce physical registers R11
运行环境:cc2540(8051)附加cjson
错误位置(案例):
/* Parse the input text to generate a number, and populate the result into item. */
static cJSON_bool parse_number(cJSON * const item, parse_buffer * const input_buffer)
{
double number = 0;
unsigned char *after_end = NULL;
unsigned char test[64];
input_buffer->offset += (size_t)(after_end - test);
return true;
}
于是笔者做了如下尝试:
将“*test”和“test”容量改为:“unsigned int”,有如下:
素材一
static cJSON_bool parse_number(cJSON * const item, parse_buffer * const input_buffer)
{
double number = 0;
unsigned int *after_end = NULL;
unsigned int test[64];
unsigned char *test2;
input_buffer->offset += (size_t)(after_end - test);
return true;
}
编译通过,笔者又做了如下尝试:
素材二
static cJSON_bool parse_number(cJSON * const item, parse_buffer * const input_buffer)
{
double number = 0;
unsigned char *after_end = NULL;
unsigned char test[64];
unsigned char *test2;
unsigned char test3;
unsigned int qw;
input_buffer->offset += (size_t)(after_end - test2);
return true;
}
编译通过,笔者又做了如下尝试:
素材三
static cJSON_bool parse_number(cJSON * const item, parse_buffer * const input_buffer)
{
double number = 0;
unsigned char *after_end = NULL;
unsigned char test[64];
unsigned char *test2;
unsigned char test3;
unsigned int qw;
qw += (size_t)(after_end - test);
return true;
}
编译通过,笔者又做了如下尝试:
素材四
static cJSON_bool parse_number(cJSON * const item, parse_buffer * const input_buffer)
{
double number = 0;
unsigned char *after_end = NULL;
unsigned char test[64];
unsigned char *test2;
unsigned char test3;
unsigned int qw;
test3 = input_buffer->offset;
input_buffer->offset = test3;
input_buffer->offset += (size_t)(after_end - test);
return true;
}
编译通过
素材五
笔者将“test3”定义为“unsigned int”编译器报相同的错误
于是笔者又做了如下尝试:
素材六
static cJSON_bool parse_number(cJSON * const item, parse_buffer * const input_buffer)
{
double number = 0;
unsigned char *after_end = NULL;
unsigned char test[64];
unsigned char *test2;
unsigned int test3;
unsigned int qw;
input_buffer->offset = input_buffer->offset;
input_buffer->offset += (size_t)(after_end - test);
return true;
}
果不其然,编译器报相同的错误,于是笔者又做了如下尝试:
素材七
static cJSON_bool parse_number(cJSON * const item, parse_buffer * const input_buffer)
{
double number = 0;
unsigned char *after_end = NULL;
unsigned char test[64];
unsigned char *test2;
unsigned char test3;
unsigned int qw;
input_buffer->offset = 0;
input_buffer->offset += (size_t)(after_end - test);
return true;
}
编译通过,笔者又做了如下尝试:
素材八
static cJSON_bool parse_number(cJSON * const item, parse_buffer * const input_buffer)
{
double number = 0;
unsigned char *after_end = NULL;
unsigned char test[64];
unsigned char *test2;
unsigned char test3;
unsigned int qw;
//input_buffer->offset = 0;
input_buffer->offset = (size_t)(after_end - test);
return true;
}
编译器通过,自此笔者有了进一步分析的素材。
首先,在此 size_t 为 unsigned int ,容量2字节。