Skip to content

lib/os/printk.c: -Wcast-function-type warning due to incompatible function pointer cast #104294

@R7J7R7M

Description

@R7J7R7M

Describe the bug

While building the hello_world sample for qemu_x86 with -Wall -Wextra flags,
two -Wcast-function-type warnings are emitted in lib/os/printk.c.

These warnings indicate a cast between incompatible function pointer types, which is
undefined behavior per the C11 standard (§6.3.2.3) and can cause issues on
certain architectures or with stricter compiler versions.

build output
lib/os/printk.c:110:51: warning: cast between incompatible function types
from 'int (*)(int, void )' to 'int ()(char, FILE *)' [-Wcast-function-type]

lib/os/printk.c:131:50: warning: cast between incompatible function types
from 'int (*)(int, void )' to 'int ()(char, FILE *)' [-Wcast-function-type]

Regression

  • This is a regression.

Steps to reproduce

west build -b qemu_x86 samples/hello_world --pristine -- -DEXTRA_CFLAGS="-Wall -Wextra"

Relevant log output

Users/gokul/Documents/zephyrproject/zephyr/lib/os/printk.c:110:51: warning: cast between incompatible function types from 'int (*)(int,  void *)' to 'int (*)(char,  FILE *)' [-Wcast-function-type]
/Users/gokul/Documents/zephyrproject/zephyr/lib/os/printk.c:131:50: warning: cast between incompatible function types from 'int (*)(int,  void *)' to 'int (*)(char,  FILE *)' [-Wcast-function-type]

Impact

Annoyance – Minor irritation; no significant impact on usability or functionality.

Environment

  • **Zephyr version:v4.3.0
  • **Board: qemu_x86
  • **OS: macOS
  • **SDK version : 0.17.4

Additional Context

No response

Metadata

Metadata

Labels

area: Base OSBase OS Library (lib/os)bugThe issue is a bug, or the PR is fixing a bugpriority: mediumMedium impact/importance bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions