Skip to content

Conversation

@adigie
Copy link
Contributor

@adigie adigie commented May 22, 2025

When both CONFIG_NET_IPV6_DAD and CONFIG_NET_IPV4_ACD are disabled, the anonymous union in struct net_if_addr ends up with no members, which results in a different struct layout between C and C++.

In C, an empty union has size 0, while in C++ it has size >=1, which shifts the offsets of the following fields.

Add a 1-byte dummy member to the union to ensure consistent layout across both compilers.

@github-actions github-actions bot added size: XS A PR changing only a single line of code area: Networking labels May 22, 2025
@github-actions github-actions bot requested review from jukkar, pdgendt, rlubos and ssharks May 22, 2025 21:11
@adigie adigie force-pushed the fix-net-if-addr branch from 60927cb to cd33fec Compare May 22, 2025 21:15
When both CONFIG_NET_IPV6_DAD and CONFIG_NET_IPV4_ACD are disabled, the
anonymous union in struct net_if_addr ends up with no members, which
results in a different struct layout between C and C++.

In C, an empty union has size 0, while in C++ it has size >=1, which
shifts the offsets of the following fields.

Add a 1-byte dummy member to the union to ensure consistent layout
across both compilers.

Signed-off-by: Adrian Gielniewski <adrian.gielniewski@nordicsemi.no>
@adigie adigie force-pushed the fix-net-if-addr branch from cd33fec to 8d37366 Compare May 23, 2025 08:27
@carlescufi carlescufi requested a review from jukkar May 23, 2025 08:43
@sonarqubecloud
Copy link

@kartben kartben merged commit 4d8ffcc into zephyrproject-rtos:main May 26, 2025
30 checks passed
@adigie adigie deleted the fix-net-if-addr branch May 27, 2025 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Networking size: XS A PR changing only a single line of code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants