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

Compilation error when _GLIBCXX_DEBUG macro is defined. #774

Closed
hn-sl opened this issue Jun 18, 2023 · 0 comments
Closed

Compilation error when _GLIBCXX_DEBUG macro is defined. #774

hn-sl opened this issue Jun 18, 2023 · 0 comments

Comments

@hn-sl
Copy link
Contributor

hn-sl commented Jun 18, 2023

#define _GLIBCXX_DEBUG
#include <highfive/H5File.hpp>

int main() {
    return 0;
}

This code produce following compilation error when tested with gcc 11.3.0.

/pth/to/include/highfive/H5DataType.hpp:253:25: error: call of overloaded ‘vector(<brace-enclosed initializer list>)’ is ambiguous
  253 |         : EnumType(std::vector<member_def>({t_members})) {}
le included from /usr/include/c++/12/vector:74,
                 from /path/to/include/highfive/H5PropertyList.hpp:11,
                 from /path/to/include/highfive/H5FileDriver.hpp:11,
                 from /path/to/include/highfive/H5File.hpp:13:
/usr/include/c++/12/debug/vector:234:7: note: candidate: ‘std::__debug::vector<_Tp, _Allocator>::vector(_Base_ref) [with _Tp = HighFive::EnumType<HighFive::details::Boolean>::member_def; _Allocator = std::allocator<HighFive::EnumType<HighFive::details::Boolean>::member_def>]’
  234 |       vector(_Base_ref __x)
      |       ^~~~~~
/usr/include/c++/12/debug/vector:213:7: note: candidate: ‘std::__debug::vector<_Tp, _Allocator>::vector(std::__debug::vector<_Tp, _Allocator>&&) [with _Tp = HighFive::EnumType<HighFive::details::Boolean>::member_def; _Allocator = std::allocator<HighFive::EnumType<HighFive::details::Boolean>::member_def>]’
  213 |       vector(vector&&) = default;
      |       ^~~~~~
/usr/include/c++/12/debug/vector:212:7: note: candidate: ‘std::__debug::vector<_Tp, _Allocator>::vector(const std::__debug::vector<_Tp, _Allocator>&) [with _Tp = HighFive::EnumType<HighFive::details::Boolean>::member_def; _Allocator = std::allocator<HighFive::EnumType<HighFive::details::Boolean>::member_def>]’
  212 |       vector(const vector&) = default;
      |       ^~~~~~

Though std::vector<member_def>({t_members}) is valid when _GLIBCXX_DEBUG is not defined, I think it is better to update it to std::vector<member_def>(t_members).

The current code std::vector<member_def>({t_members}) creates a temporary vector from {t_members} and calls the move constructor unnecessarily. Since t_members is already of type std::initializer_list<member_def>, directly passing it to the constructor of std::vector<member_def> will resolve this issue.

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