http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51202
Bug #: 51202
Summary: Whether the “else” sentence is necessary to guarantee
“if” block works correctly in gcc 3.4.4
Classification: Unclassified
Product: gcc
Version: 3.4.4
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: [email protected]
ReportedBy: [email protected]
/***********************************************************/
release version has problam!!!
/***********************************************************/
//转发485数据
testflag = cb_dma_rx_x(pFPGATOHMI->keydata, IO_OFFSET_X_LEN);
0x000079e0 <OptTask+52>: ldw r4,-32744(gp)
0x000079e4 <OptTask+56>: movi r5,9
0x000079f0 <OptTask+68>: addi r4,r4,132
0x000079f4 <OptTask+72>: call 0x6f04 <cb_dma_rx_x>
0x000079f8 <OptTask+76>: stw r2,-32408(gp)
if(testflag == 0)
0x00007a00 <OptTask+84>: beq r2,zero,0x7a90 <OptTask+228>
Ext485_dma_send(pFPGATOHMI->keydata, IO_OFFSET_X_LEN);
0x000079fc <OptTask+80>: movi r5,9
0x00007a90 <OptTask+228>: ldw r4,-32744(gp)
0x00007a94 <OptTask+232>: addi r4,r4,132
0x00007a98 <OptTask+236>: call 0x6bd4 <Ext485_dma_send>
//else
// testflag = 0;
testflag = Ext485_rx_x(pFPGATOHMI->keydata, IO_OFFSET_X_LEN);
0x00007a04 <OptTask+88>: ldw r4,-32744(gp)
0x00007a08 <OptTask+92>: movi r5,9
0x00007a0c <OptTask+96>: addi r4,r4,132
0x00007a10 <OptTask+100>: call 0x6c5c <Ext485_rx_x>
0x00007a14 <OptTask+104>: stw r2,-32408(gp)
0x00007a9c <OptTask+240>: ldw r4,-32744(gp)
0x00007aa0 <OptTask+244>: movi r5,9
0x00007aa4 <OptTask+248>: addi r4,r4,132
0x00007aa8 <OptTask+252>: call 0x6c5c <Ext485_rx_x>
0x00007aac <OptTask+256>: stw r2,-32408(gp)
if(testflag == 0)
0x00007a1c <OptTask+112>: beq r2,zero,0x7ab8 <OptTask+268>
0x00007ab4 <OptTask+264>: bne r2,zero,0x7a20 <OptTask+116>
cb_dma_send_y(pFPGATOHMI->keydata, IO_OFFSET_X_LEN);
0x00007a18 <OptTask+108>: movi r5,9
0x00007ab0 <OptTask+260>: movi r5,9
0x00007ab8 <OptTask+268>: ldw r4,-32744(gp)
0x00007abc <OptTask+272>: addi r4,r4,132
0x00007ac0 <OptTask+276>: call 0x6e7c <cb_dma_send_y>
/***********************************************************/
release version has no problam
/***********************************************************/
//转发485数据
testflag = cb_dma_rx_x(pFPGATOHMI->keydata, IO_OFFSET_X_LEN);
0x000079e0 <OptTask+52>: ldw r4,-32744(gp)
0x000079e4 <OptTask+56>: movi r5,9
0x000079e8 <OptTask+60>: addi r4,r4,132
0x000079ec <OptTask+64>: call 0x6f04 <cb_dma_rx_x>
if(testflag == 0)
0x000079f0 <OptTask+68>: beq r2,zero,0x7a6c <OptTask+192>
Ext485_dma_send(pFPGATOHMI->keydata, IO_OFFSET_X_LEN);
0x00007a6c <OptTask+192>: ldw r4,-32744(gp)
0x00007a70 <OptTask+196>: movi r5,9
0x00007a74 <OptTask+200>: stw zero,-32408(gp)
0x00007a78 <OptTask+204>: addi r4,r4,132
0x00007a7c <OptTask+208>: call 0x6bd4 <Ext485_dma_send>
else
testflag = 1;
0x000079f8 <OptTask+76>: movi r2,1
0x00007a04 <OptTask+88>: stw r2,-32408(gp)
testflag = Ext485_rx_x(pFPGATOHMI->keydata, IO_OFFSET_X_LEN);
0x000079f4 <OptTask+72>: ldw r4,-32744(gp)
0x000079fc <OptTask+80>: movi r5,9
0x00007a00 <OptTask+84>: addi r4,r4,132
0x00007a08 <OptTask+92>: call 0x6c5c <Ext485_rx_x>
0x00007a0c <OptTask+96>: stw r2,-32408(gp)
0x00007a80 <OptTask+212>: ldw r4,-32744(gp)
0x00007a84 <OptTask+216>: movi r5,9
0x00007a88 <OptTask+220>: addi r4,r4,132
0x00007a8c <OptTask+224>: call 0x6c5c <Ext485_rx_x>
0x00007a90 <OptTask+228>: stw r2,-32408(gp)
if(testflag == 0)
0x00007a10 <OptTask+100>: beq r2,zero,0x7a98 <OptTask+236>
0x00007a94 <OptTask+232>: bne r2,zero,0x7a14 <OptTask+104>
cb_dma_send_y(pFPGATOHMI->keydata, IO_OFFSET_X_LEN);
0x00007a98 <OptTask+236>: ldw r4,-32744(gp)
0x00007a9c <OptTask+240>: movi r5,9
0x00007aa8 <OptTask+252>: addi r4,r4,132
0x00007aac <OptTask+256>: call 0x6e7c <cb_dma_send_y>
/***********************************************************/
question:
1. nios2-gcc 3.4.4; gdb 6.5.50.20060706-cvs (Cygwin-special)
2. In the first “if” block, if “else” sentence is not used, then “if”
condition will fail when entering “if” block. But if the “else” sentence is
used, this “if” condition works correctly. And I have met similar problem
before, so I wonder whether the “else” sentence is necessary to guarantee “if”
block works correctly.
3. There is no above problems in debug mode, while there is above problems
in release mode.
/***********************************************************/