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

Clangd crash (LLVM issue?) when including sol headers in a C++20 module #1619

Closed
davidgreen opened this issue Aug 8, 2024 · 2 comments
Closed

Comments

@davidgreen
Copy link

Short version: including sol in the global module fragment of a C++20 module causes clangd to crash. The code otherwise compiles (msvc) and runs fine.

I use CLion which uses Clangd for syntax highlighting. Clangd uses LLVM under the hood. The code is actually compiled with msvc.

I have hit a strange issue where if I create a module and 1) include sol/sol.hpp in the global module fragment and 2) use any sol classes in function definitions inside the module then syntax highlighting breaks for all downstream code that imports the module.

I narrowed this down to an issue with clangd crashing, which implies LLVM is failing to compile sol. Could be a red herring, but if I don't use the single header and then remove sol/table.hpp and sol/state.hpp from sol/sol.hpp the error goes away. The clangd crash dumps are not particularly helpful other than mentioning that templates relating to std::optional are undefined. Possibly an issue with the sol optional implementation breaking LLVM (but I am not actually sure)?

Note that I have tried this with both the latest release and the newest development versions (which includes the 'construct' issue fix) required for LLVM issues.

I'm not sure how to proceed with debugging this. Any help or suggestions would be beneficial. I realise that module support is still early for LLVM.

@davidgreen
Copy link
Author

davidgreen commented Aug 8, 2024

I think I have narrowed it down to this line in inheritance.hpp

using inheritance_unique_cast_function = decltype(&inheritance<void>::type_unique_cast<void>);

@davidgreen
Copy link
Author

Seems to be fixed by replacing this line in inheritance.hpp:

using inheritance_unique_cast_function = decltype(&inheritance<void>::type_unique_cast<void>);

with the explicit function pointer definition, avoiding the use of decltype:

using inheritance_unique_cast_function = int (*)(void*, void*, const string_view&, const string_view&);

I haven't fully tested it yet but clangd seems happy at least. Still seems like an LLVM bug but happy to mark this as closed.

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

1 participant