Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

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

@tiagomacarios

Description

@tiagomacarios

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions