2020-09-26

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字节。

未完待续

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容