What happens on GCC 14.2? I know this one is preferred :-) -- CeDeROM, SQ7MHZ, http://www.tomek.cedro.info
On Sun, Feb 22, 2026 at 11:12 PM Peter Barada <[email protected]> wrote: > > This is _really_ weird. I'm seeing what looks (to me) to be a bug in > arm-none-eabig-gcc where it _may_ generate format warnings (or not) when > run over functionally equivalent source using same compilation options. > > I'm trying to understand why a syslog call using a format of "%08x" and > an argument of uint32_t doesn't cause a format warning when built using > arm-none-eabi-gcc (version 13.2.1 20231009) on my Ubuntu machine. > > I configured nuttx for nucelo-h743zi2:jumbo, tweaked the configuration > to enable DEBUG_IRQ_INFO, and built with V=1 to get the compiler command > line for arch/arm/src/chip/stm32_irq.c: > > tools/configure.sh -l nucleo-h743zi2jumbo > kconfig-tweak --file .config -e DEBUG_IRQ_INFO > make V=1 -j $(nproc) > > Then chdir into arch/arm/src and generate preprocessed source of > chip/stm32_irq.c into /tmp/stm32_irq.c using the complication command > from the build: > > cd arch/arm/src > # setup BASE_DIR to root of nuttx tree > BASE_DIR=/home/peter/git/nuttx/github/nucleo-h743zi2-warnings/nuttx > # setup COMPILER_OPTIONS for what gets passed to gcc > COMPILER_OPTIONS="-Wstrict-prototypes -Wno-attributes -Wno-unknown-pragmas" \ > " -Wno-psabi -Os -fno-strict-aliasing -fomit-frame-pointer" \ > " --param=min-pagesize=0 -fno-common -Wall -Wshadow -Wundef" \ > " -ffunction-sections -fdata-sections "-g" -mlittle-endian" \ > " -march=armv7e-m -mtune=cortex-m7 -mfpu=fpv5-d16 -mfloat-abi=hard" \ > " -mthumb -Wa,-mthumb -Wa,-mimplicit-it=always -isystem" > > # Generate /tmp/stm32_irq.c from chip/stm32_irq.c > arm-none-eabi-gcc -E $COMPILER_OPTIONS $BASE_DIR/include -D__NuttX__ \ > -DNDEBUG -D__KERNEL__ -I $BASE_DIR/arch/arm/src/chip \ > -I $BASE_DIR/arch/arm/src/common -I $BASE_DIR/arch/arm/src/armv7-m \ > -I $BASE_DIR/sched chip/stm32_irq.c -o /tmp/stm32_irq.c > > # Compile the result file using same compiler options: > arm-none-eabi-gcc -E $COMPILER_OPTIONS $BASE_DIR/include -D__NuttX__ \ > -DNDEBUG -D__KERNEL__ -I $BASE_DIR/arch/arm/src/chip \ > -I $BASE_DIR/arch/arm/src/common -I $BASE_DIR/arch/arm/src/armv7-m \ > -I $BASE_DIR/sched chip/stm32_irq.c -o /tmp/stm32_irq.c > > # So far no errors (yes, get a preprocessow warning, can ignore) > > The above should just generate a preprofcessing warning. Now it gets > strange: > > # Remove _all_ the preprocessor generated linemarkers and compile again: > sed -ie '/^#/d' /tmp/stm32_irq.c > > arm-none-eabi-gcc -E $COMPILER_OPTIONS $BASE_DIR/include -D__NuttX__ \ > -DNDEBUG -D__KERNEL__ -I $BASE_DIR/arch/arm/src/chip \ > -I $BASE_DIR/arch/arm/src/common -I $BASE_DIR/arch/arm/src/armv7-m \ > -I $BASE_DIR/sched chip/stm32_irq.c -o /tmp/stm32_irq.c > > And now I see format warnings (here's the first): > > /tmp/stm32_irq.c: In function 'stm32_dumpnvic': > > /tmp/stm32_irq.c:4875:12: warning: format '%x' expects argument of type > 'unsigned int', but argument 4 has type 'uint32_t' {aka 'long unsigned int'} > [-Wformat=] > 4875 | syslog(6, "%s: " > | ^~~~~~ > ...... > 4878 | getreg32((0xe000e000 + 0x0d04)), getreg32((0xe000e000 + 0x0d08)) > | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > | | > | uint32_t {aka long unsigned int} > /tmp/stm32_irq.c:4876:20: note: format string is defined here > 4876 | " INTCTRL: %08x VECTAB: %08x\n" > | ~~~^ > | | > | unsigned int > | %08lx > > Could someone who builds stm32 on Ubuntu try out above commands > (changing BASE_DIR to match your tree) and tell me if you see same > results where format warnings magically appear? Any ideas why gcc > generates format warnings over same source - only after removing all the > preprocessor linemarkers? > > Thanks in advance! > > -- > Peter Barada > [email protected]
