Skip to content

init: fix compilation for broken compilers #93027

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lyakh
Copy link
Collaborator

@lyakh lyakh commented Jul 11, 2025

Some (broken) compilers fail to handle

struct x {
	union {
		type_a *a;
		type_b *b;
	};
};

correctly. Replace that with an equivalent but simpler

union x {
	type_a *a;
	type_b *b;
};

Sample build failure log: https://sof-ci.01.org/sofpr/PR10113/build13856/build/firmware_community/tgl.log

Some (broken) compilers fail to handle

struct x {
	union {
		type_a *a;
		type_b *b;
	};
};

correctly. Replace that with an equivalent but simpler

union x {
	type_a *a;
	type_b *b;
};

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Copy link

@lyakh
Copy link
Collaborator Author

lyakh commented Jul 11, 2025

As explained in #93020 this bug can also be reproduced by building pure Zephyr for intel_adsp/cavs25 using the same Cadence toolchain

@henrikbrixandersen
Copy link
Member

Some (broken) compilers fail to handle

struct x {
	union {
		type_a *a;
		type_b *b;
	};
};

correctly. Replace that with an equivalent but simpler

union x {
	type_a *a;
	type_b *b;
};

This removes the encapsulation, though. With a struct, more members can be added later without breaking an API.

@cfriedt
Copy link
Member

cfriedt commented Jul 11, 2025

@lyakh - it looks like the code is being compiled with -std=c99. However, anonymous unions were not added to ISO C until C11.

Maybe the compiler isn't actually broken.

Can you try building with the appropriate settings?

With Zephyr, you should be able to use CONFIG_STD_C11=y.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants