In my embedded project, using the IAR EWARM dev tools (v7.10.3), I have the following code snippet:
uint32_t packet_sync = 0; uint32_t synced = 0; uint32_t gpio = 0; while (1) { if ((packet_sync != 0) && ((packet_sync = gpio) == 0)) { if (synced < 2) { synced++; } } };
For some reason, when I compile the code, the compiler gets stuck in the middle of the compilation. I tried playing around with various constructs, and it seems that any minor changes I make fixes the problem (but may also make the code incorrect). For example, adding NOP to # 6a and the code will compile successfully:
if (synced < 2) { __NOP(); synced++; }
Other examples of successful changes are deleting line # 7 or changing line # 5 as:
if ((packet_sync != 0) && ((gpio) == 0)) {
and a few more options.
I don't see a rule C violation in the problematic code, and it compiles fine in Visual Studio 2013. Am I missing something? Why is this code not compiling?
* Note: the code presented is an extraction of the actual code and is logically meaningless.
Update: Code compiled with optimization level "High" / "Balanced". At lower levels of optimization, compilation ends just fine.
It also gets stuck when using the "High" level, but removes the optimization options in the "Enabled conversions:" field. Also stuck for the “Speed” and “Size” options.
source share