Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Strange compiler warning

Posted by ksoldavin on March 25, 2014

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

Posted by rtel on March 25, 2014

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:



Strange compiler warning

Posted by ksoldavin on March 26, 2014

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

Posted by rtel on March 26, 2014

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.


Strange compiler warning

Posted by ksoldavin on March 26, 2014

Wonderful! Thank you for all your help.

[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]

Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS v10.2.1 is available for immediate download. MIT licensed, includes 64-bit RISC-V, NXP Cortex-M33 demo, Nuvoton Cortex-M23 demo & STM32H745 dual core (AMP) demo.

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Cadence Tensilica Cortes

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers





STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner