This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Hi.
I'm using the GCC compiler for PPC405 as delivered with Xilinx EDK 8.1. The exact version is: powerpc-eabi-gcc (GCC) 3.4.1 ( Xilinx EDK 8.1.1 Build EDK_I.19.3 190106 )
I found a bug in the code generation.
My code is a serial receiver and uses an uninitialized uchar nData:
uchar nBits; uchar nData; for (nBits=0; nBits<8; nBits++) { nData >>= 1; // the bug is related to this statement if (function()) nData |= 0x80; }
Although nData is not initialized, the correct state after the first "nData >>= 1" statement would be any value between 0x00 and 0x7f. However, on my target board I found it to be >= 0x80.
And if nData is not initialized you are invoking undefined behavior according to the C/C++ standards so the behavior here is ok. Yes you are not expecting this behavor but that is not our fault you are depening on undefined behavior.
Thanks, Andrew Pinski
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |