Created attachment 46254 [details] a simple testcase test case attached, and we can see the code in line 42 clear the memory point with pstruDlTpcPara, so the value in the memory cross the line 42 is different. 39 TpcFingerNum[TpcIdex][0] = *(UINT32*)(void*)pstruDlTpcPara; 40 TpcFingerNum[TpcIdex][1] = pstruDlTpcPara->ucThreeSlotFngNum; 41 42 *(volatile UINT32*)(void*)pstruDlTpcPara = 0; 43 44 TpcFingerNum[TpcIdex][2] = *(UINT32*)(void*)pstruDlTpcPara; 45 TpcFingerNum[TpcIdex][3] = pstruDlTpcPara->ucThreeSlotFngNum; base on the gcc 7.3, in the dumpfile test.c.037t.fre1, we can see the value _6 get before the operator of clear the memory. So it miss the data dependence base on memory. (Generated by cmd:../../GCC/gcc-730/binary/bin/gcc test.c -dAp -S -O2 -g3 -fdump-tree-all) 37 _4 = MEM[(struct STRU_CCH_DLTPC_PARA *)&gastruDlTpcPara][_1].ucThreeSlotFngNum; 38 _6 = (unsigned int) _4; 39 TpcFingerNum[TpcIdex.0_2][1] = _6; 40 MEM[(volatile UINT32 *)pstruDlTpcPara_20] ={v} 0; 41 _8 = MEM[(UINT32 *)pstruDlTpcPara_20]; 42 TpcFingerNum[TpcIdex.0_2][2] = _8; 43 TpcFingerNum[TpcIdex.0_2][3] = _6;
You are violating C aliasing rules for sure.
Use either -fno-strict-aliasing or change STRU_CCH_DLTPC_PARA to use an union and access it via that.
but it doesn't warning anything, even with -Wstrict-aliasing -Wall. Accord to http://blog.sina.com.cn/s/blog_74caf0ce010173up.html, We expect an warning similar the following infomation. warning: dereferencing type-punned pointer will break strict-aliasing rules