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

Unknown enum variants returned by libclang cause crash in clang-sys builds targeting earlier versions of libclang #42

Closed
tcosprojects opened this issue Oct 4, 2016 · 1 comment

Comments

@tcosprojects
Copy link

If clang-sys is compiled to target clang_3_5 but is linked against libclang 3.9 a crash (SIGSEGV or stack overflow) occurs when libclang returns an enum variant unknown to clang-sys that is then used in a match expression.

I filed a "bug" with rust-lang although it seems this is intended behavior for rust. Possible solutions are to cast the enums to an int or use int constants instead to avoid this problem, perhaps re-wrapping them as an enum. rust-lang/rust#36927

Some other discussions of this issue:

https://internals.rust-lang.org/t/c-style-enums-in-ffi-and-a-proposal-to-lump-in-with-unions/2744
https://users.rust-lang.org/t/backward-compatibility-of-enums/5224
rust-lang/rfcs#757

@KyleMayes
Copy link
Owner

Well, this is a problem. It also made me think of a related problem. If you are using libclang 3.9 (but compiled for libclang 3.5) and ask for the CXCallingConv of a function with the Swift calling convention (added in 3.9), what should be returned? libclang 3.5 doesn't know what Swift is, so should it panic? Return CXCallingConv::Default? I'll need to think about this.

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

No branches or pull requests

2 participants