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

Bond generated headers don't work for clang in c++20 #1176

Open
tiagomacarios opened this issue Dec 5, 2022 · 2 comments
Open

Bond generated headers don't work for clang in c++20 #1176

tiagomacarios opened this issue Dec 5, 2022 · 2 comments
Labels

Comments

@tiagomacarios
Copy link
Member

tiagomacarios commented Dec 5, 2022

Bond generates code as follows:
https://godbolt.org/z/a4qnbcjeh

#include <vector>

struct forward_decl;

struct S{
    std::vector <forward_decl> m;

    S(){};
};

struct forward_decl{};

But this does not work in C++20 (in clang) because the constructor will be instantiated with the forward declaration and compilation will fail.

A possible fix is to move the constructor body until after all entities have bee fully defined:
https://godbolt.org/z/6YjarYx3c

#include <vector>

struct forward_decl;

struct S {
    std::vector<forward_decl> m;

    S();
};

struct forward_decl {};

inline S::S() {}

Office is currently hitting this when trying to update to C++20.

@chwarr chwarr added the bug label Dec 6, 2022
@chwarr
Copy link
Member

chwarr commented Dec 6, 2022

This change makes sense and should be backward compatible to C++11 as well. Feel free to submit a PR with the changes to code generation.

Does S::S() {} need to be marked inline as it won't be inside a class definition?

@tiagomacarios
Copy link
Member Author

yes it will need inline. I am not familiar with Haskell, nor do I have an environment set. I presume this is a simple change, could you author it? This is currently blocking us. If you prefer I can create an internal bug on you team - just provide me the correct area path.

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

No branches or pull requests

2 participants