Strange compiler warning

I am getting a compiler warning that I have not seen before and I’m not sure if I should be concerned. I am running version 7.6 on a STM32F4 using CodeSourcery Lite 2013.11-24 tool chain. This is the warning I am seeing: tasks.c:2526:56: warning: multiple accesses to volatile structure member because of packed attribute [-fstrict-volatile-bitfields] I see this warning in three different places in the tasks.c source code. The code runs fine but I always try to track down all compiler warnings. The compiler flag that is causing the warning is “-fpack-struct” which I need for other parts of my code. Any thoughts? Thank you Keith

Strange compiler warning

It is warning you that, because you have packed the structures, it is taking three memory accesses to read a single member out of a structure – and because that member is marked as volatile the compiler rightly is cautioning you that the member’s value might change between the first and third access. It is probably not a real issue, please post the three line numbers that generate the warning from the link below and I will let you know: https://sourceforge.net/p/freertos/code/HEAD/tree/tags/V7.6.0/FreeRTOS/Source/tasks.c Regards.

Strange compiler warning

Thanks for the prompt help. I am seeing the warnings on line numbers: 2526 pxTaskStatusArray[ uxTask ].xTaskNumber = pxNextTCB->uxTCBNumber; 2532 pxTaskStatusArray[ uxTask ].uxBasePriority = pxNextTCB->uxBasePriority; 2542 pxTaskStatusArray[ uxTask ].ulRunTimeCounter = pxNextTCB->ulRunTimeCounter;

Strange compiler warning

These fall inside a helper function, rather than in the actual kernel code. The function is only ever called with the scheduler suspended so there is no chance of the data changing during the volatile access – so nothing to worry about. You may find that some of the volatiles inside that function are only actually declared volatile because some compilers will generate warning messages if they are not. Regards.

Strange compiler warning

Wonderful! Thank you for all your help.