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

Clang: Compilation error with visitable struct include template class #20

Open
alemariusnexus opened this issue Jun 30, 2021 · 0 comments

Comments

@alemariusnexus
Copy link

I ran into problems getting the following to work in Clang 12.0.0, using the latest master of visit_struct:

template <typename T>
struct TemplatedStruct
{
	struct Visitable
	{
		BEGIN_VISITABLES(Visitable);
		VISITABLE(int, a);
		VISITABLE(int, b);
		VISITABLE(int, c);
		END_VISITABLES;
	};
};

int main(int argc, char** argv)
{
	TemplatedStruct<int> test;
	return 0;
}

For this minimal example, Clang outputs the following:

main.cpp:12:3: error: functions that differ only in their return type cannot be overloaded
VISITABLE(int, c);
^~~~~~~~~~~~~~~~~
visit_struct/include/visit_struct/visit_struct_intrusive.hpp:382:3: note: expanded from macro 'VISITABLE'
Visit_Struct_Get_Visitables__(::visit_struct::detail::Rank<VISIT_STRUCT_GET_REGISTERED_MEMBERS::size + 1>);
^
main.cpp:11:3: note: previous declaration is here
VISITABLE(int, b);
^~~~~~~~~~~~~~~~~
visit_struct/include/visit_struct/visit_struct_intrusive.hpp:382:3: note: expanded from macro 'VISITABLE'
Visit_Struct_Get_Visitables__(::visit_struct::detail::Rank<VISIT_STRUCT_GET_REGISTERED_MEMBERS::size + 1>);
^
1 error generated.

Both GCC and MSVC compile this example just fine, only Clang has problems with it. The problem happens only with visitable structs inside template classes. Without the template, it works just fine. Curiously, it also works fine with exactly 2 visitables in the struct - it starts failing for 3.

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