Cypress技术论坛
直播中

曹珉

8年用户 203经验值
私信 关注
[问答]

编译器生成错误代码

我的代码显示创建无限循环(线位于分支线以上)
switch语句的无辜的结束:
TSH案:
/一些计算
打破;默认:break;}
和组装:
664 01e6 fff7feff BL mymemcpy 665。lvl57:217:,UART。C *打破;666. LOC 1 217 0 667 01ea 00e0 B。L23 668. lvl58:669. L26:670。L80:671 01ec事项B。L80 672. lvl59:673. L23:674。lbe23:231:,UART。C * } 675。赛段677需要LOC 1 231 0 676 @ SP。lvl60:67801ee f7bd流行{ R0、R1、R2、R4、R5、R6、R7、PC } 679。L85:

以上来自于百度翻译


     以下为原文
  The code I show create endless loop (line 671 branch to line above)
    Innocent end of switch statement:
    case TSH:
    // some calculations
                        break;
                     default:
                     break;
                 }
    And assembly:
    664 01e6 FFF7FEFF         bl    mymemcpy
  665                  .LVL57:
  217:.Uart.c      ****                     break;
  666                      .loc 1 217 0
  667 01ea 00E0             b    .L23
  668                  .LVL58:
  669                  .L26:
  670                  .L80:
  671 01ec FEE7             b    .L80
  672                  .LVL59:
  673                  .L23:
  674                  .LBE23:
  231:.Uart.c      ****     }
  675                      .loc 1 231 0
  676                      @ sp needed for prologue
  677                  .LVL60:
  678 01ee F7BD             pop    {r0, r1, r2, r4, r5, r6, r7, pc}
  679                  .L85:

回帖(7)

曹珉

2019-1-16 07:51:45
看起来好像是没有文件的陷阱抓住错误的跳跃。
我追踪可能发生的情况。我找到了Label.L26在其他函数中引用
在这个函数中有{{}同时(rddx)!= WRUNDX)
当条件为真而不是跳到循环开始时,它跳转到不同函数的SUSEC语句的末尾。

以上来自于百度翻译


     以下为原文
  It looks as if undocumented trap to catch wrong jumps
    I trace the condition it may happen. I found label .L26 is referenced in other function unrelated at all
    In this function there is do{}while(rdindx != wrindx)
    when condition is true instead of jump to begin of loop it jumps to end of swithc statement in different function
举报

曹珉

2019-1-16 08:07:10
我找到了其他的原因:
不知何故,复制粘贴粘贴了两次代码,产生的代码是
空ParseInput(CMD*PTR){(rddx)!{WRUNDX){} UTIN 16和= 0;UITN8印记;
……
我不知道它编译的时候甚至没有警告。
然而这是无尽的循环

以上来自于百度翻译


     以下为原文
  I found the reason somwhere else:
    Somehow the copy & paste inserted the code twice, and the code produced was
    void ParseInput(Cmd* ptr){
    while(rdindx != wrindx){
    }
   
    uint16  sum = 0;
uint8 indx;
    ...........................
    I have no idea while it compiled without even warning.
    However it was the endless loop
举报

王琳

2019-1-16 08:20:07
Sego
我认为你可以确信GCC没有产生错误的代码,GCC被用在十亿的手机中,所以已经发现了任何明显的bug。从代码片段中,我看不出真正的错误在哪里,可能你已经设置了一个优化,有时会导致结果正确,但很难理解。
鲍勃

以上来自于百度翻译


     以下为原文
  Sego,
    I think you can be darn sure that GCC is not producing wrong code, GCC is used in a billion of cellphones, so any obvious bug would have been found already. From your code snippets I cannot see where the real error has been, probably you've set an optimization which sometimes lead to results which work correctly but are difficult to understand.
     
    Bob
举报

杨军

2019-1-16 08:27:54
鲍伯,如果我谷歌“GCC ErATA”,我得到很多点击,一些相当近?
如果我去http://gcc.gnu.org/错误/修复更多信息。
似乎仍然是一个进展中的工作。
问候,Dana。

以上来自于百度翻译


     以下为原文
  Bob, if I google "gcc eratta" I get lots of hits, some fairly recent ?
     
    If I go to               http://gcc.gnu.org/ more info on bugs/fixes.
     
    Seems like still a work in progress.
     
    Regards, Dana.
举报

更多回帖

发帖
×
20
完善资料,
赚取积分