Processor STM32F4 (Cortex M4), uVision 4.54, C++ V4.1.0.894 (in C++ module), Optimization level O1:
The following construction does not recognize the code change in the memcpy function:
... long long ll= 0; // copy the upper 6 bytes of ll from the unaligned data source pbData memcpy( ((BYTE*)&ll)+2, pbData, 6); if( !ll) return; ... the following code will never be reached, as ll is not reloaded in the preceding "if( !ll)" condition. (The return statement is ALWAYS used - no code is generated for the "if( !ll)" condition).
It would be very nice, if the compiler in such a case would generate a warning "Condition without use / always true" or so (as definitely any other C/C++ compiler I know would do). (This case can be solved by replacing the "ll=0" by "*(short*)&ll= 0" - but it took me quite a time to recognized the problem - I did not expect this).
Also in this case, I would appreciate very much a warning for missing brackets:
int iStatus; #define STATUS_Bit1 0x01 #define STATUS_Bit2 0x04 if( iStatus == STATUS_Bit1 | STATUS_Bit2){ ... this code is then executed always, as the compiler seems to handle "==" and "|" with identic priority, so it translates the condition as "(iStatus == STATUS_Bit1) | STATUS_Bit2" }
Here any other C/C++ compiler I use would give two warnings: "Using ambiguous operators without brackets" and "Condition without use / always true".
Please consider to add these two warnings in some future compiler update if possible.