Skip to content
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

don't trust completeStruct for typeinfo gen of imported C++ types [backport] #24166

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

Conversation

metagn
Copy link
Collaborator

@metagn metagn commented Sep 23, 2024

fixes #24159, refs #23761, refs #15928

Since #23761 the compiler generates typeinfo for imported types if they are marked completeStruct. However the C++ imported Atomic[T] type is also marked completeStruct and has a fake field raw: T as a hack to calculate the correct size, which the typeinfo generation tries to refer to. To prevent this, don't generate typeinfo for any imported C++ type regardless of completeStruct. Alternatively the "size known" meaning of completeStruct could be split into another pragma like sizeKnown for Atomic[T] to use.

Ideally this would be fixed by Atomic[T] no longer being completeStruct and its size being calculated via size: sizeof(T) instead, but the compiler does not support this and it would take a lot of effort to implement, so this is a temporary fix until that is done.

This is marked as backport since #23761 was backported.

@arnetheduck
Copy link
Contributor

completeStruct affects the ability to generate ABI checks, the lack of which regularly cause abi incompatibilities which lead to hard-to-debug errors - removing it while relying on matching ABI (including size, alignment etc) is never a good idea and as long as atomic uses the "underlying" implementation, there should be an abi check in place.

@metagn
Copy link
Collaborator Author

metagn commented Sep 23, 2024

ABI checks shouldn't be affected, the size computation behavior of completeStruct isn't changed (the only other check for completeStruct in the compiler), which means the ABI check is still added. Only the typeinfo generation is disabled for C++ imports, which was already the case before #23761.

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

Successfully merging this pull request may close these issues.

invalid C++ codegen in --mm:refc with Thread/Atomic/createThread
2 participants