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 with g++11 #322

Closed
tomhughes opened this issue Jan 12, 2021 · 6 comments
Closed

Compilation error with g++11 #322

tomhughes opened this issue Jan 12, 2021 · 6 comments

Comments

@tomhughes
Copy link
Contributor

Compiling this file:

#include <osmium/io/any_input.hpp>

with g++ 11 (not yet released) fails:

In file included from /usr/include/osmium/memory/buffer.hpp:38,
                 from /usr/include/osmium/builder/builder.hpp:36,
                 from /usr/include/osmium/builder/osm_object_builder.hpp:36,
                 from /usr/include/osmium/io/detail/o5m_input_format.hpp:36,
                 from /usr/include/osmium/io/o5m_input.hpp:42,
                 from /usr/include/osmium/io/any_input.hpp:48,
                 from osm.cc:1:
/usr/include/osmium/osm/entity.hpp: In instantiation of ‘TSubitem& osmium::detail::subitem_of_type(TIter, const TIter&) [with TSubitem = const osmium::TagList; TIter = osmium::memory::CollectionIterator<const osmium::memory::Item>]’:
/usr/include/osmium/osm/object.hpp:333:83:   required from here
/usr/include/osmium/osm/entity.hpp:54:29: error: use of deleted function ‘osmium::memory::Collection<osmium::Tag, osmium::item_type::tag_list>::Collection(osmium::memory::Collection<osmium::Tag, osmium::item_type::tag_list>&&)’
   54 |             static TSubitem subitem{};
      |                             ^~~~~~~
In file included from /usr/include/osmium/osm/area.hpp:36,
                 from /usr/include/osmium/builder/osm_object_builder.hpp:38,
                 from /usr/include/osmium/io/detail/o5m_input_format.hpp:36,
                 from /usr/include/osmium/io/o5m_input.hpp:42,
                 from /usr/include/osmium/io/any_input.hpp:48,
                 from osm.cc:1:
/usr/include/osmium/memory/collection.hpp:117:15: note: ‘osmium::memory::Collection<osmium::Tag, osmium::item_type::tag_list>::Collection(osmium::memory::Collection<osmium::Tag, osmium::item_type::tag_list>&&)’ is implicitly deleted because the default definition would be ill-formed:
  117 |         class Collection : public Item {
      |               ^~~~~~~~~~
/usr/include/osmium/memory/collection.hpp:117:15: error: use of deleted function ‘osmium::memory::Item::Item(osmium::memory::Item&&)’
In file included from /usr/include/osmium/memory/buffer.hpp:36,
                 from /usr/include/osmium/builder/builder.hpp:36,
                 from /usr/include/osmium/builder/osm_object_builder.hpp:36,
                 from /usr/include/osmium/io/detail/o5m_input_format.hpp:36,
                 from /usr/include/osmium/io/o5m_input.hpp:42,
                 from /usr/include/osmium/io/any_input.hpp:48,
                 from osm.cc:1:
/usr/include/osmium/memory/item.hpp:146:13: note: declared here
  146 |             Item(Item&&) = delete;
      |             ^~~~
In file included from /usr/include/osmium/memory/buffer.hpp:38,
                 from /usr/include/osmium/builder/builder.hpp:36,
                 from /usr/include/osmium/builder/osm_object_builder.hpp:36,
                 from /usr/include/osmium/io/detail/o5m_input_format.hpp:36,
                 from /usr/include/osmium/io/o5m_input.hpp:42,
                 from /usr/include/osmium/io/any_input.hpp:48,
                 from osm.cc:1:
/usr/include/osmium/osm/entity.hpp: In instantiation of ‘TSubitem& osmium::detail::subitem_of_type(TIter, const TIter&) [with TSubitem = osmium::ChangesetDiscussion; TIter = osmium::memory::CollectionIterator<osmium::memory::Item>]’:
/usr/include/osmium/osm/changeset.hpp:430:87:   required from here
/usr/include/osmium/osm/entity.hpp:54:29: error: use of deleted function ‘osmium::memory::Collection<osmium::ChangesetComment, osmium::item_type::changeset_discussion>::Collection(osmium::memory::Collection<osmium::ChangesetComment, osmium::item_type::changeset_discussion>&&)’
   54 |             static TSubitem subitem{};
      |                             ^~~~~~~
In file included from /usr/include/osmium/osm/area.hpp:36,
                 from /usr/include/osmium/builder/osm_object_builder.hpp:38,
                 from /usr/include/osmium/io/detail/o5m_input_format.hpp:36,
                 from /usr/include/osmium/io/o5m_input.hpp:42,
                 from /usr/include/osmium/io/any_input.hpp:48,
                 from osm.cc:1:
/usr/include/osmium/memory/collection.hpp:117:15: note: ‘osmium::memory::Collection<osmium::ChangesetComment, osmium::item_type::changeset_discussion>::Collection(osmium::memory::Collection<osmium::ChangesetComment, osmium::item_type::changeset_discussion>&&)’ is implicitly deleted because the default definition would be ill-formed:
  117 |         class Collection : public Item {
      |               ^~~~~~~~~~
/usr/include/osmium/memory/collection.hpp:117:15: error: use of deleted function ‘osmium::memory::Item::Item(osmium::memory::Item&&)’
In file included from /usr/include/osmium/memory/buffer.hpp:36,
                 from /usr/include/osmium/builder/builder.hpp:36,
                 from /usr/include/osmium/builder/osm_object_builder.hpp:36,
                 from /usr/include/osmium/io/detail/o5m_input_format.hpp:36,
                 from /usr/include/osmium/io/o5m_input.hpp:42,
                 from /usr/include/osmium/io/any_input.hpp:48,
                 from osm.cc:1:
/usr/include/osmium/memory/item.hpp:146:13: note: declared here
  146 |             Item(Item&&) = delete;
      |             ^~~~
In file included from /usr/include/osmium/memory/buffer.hpp:38,
                 from /usr/include/osmium/builder/builder.hpp:36,
                 from /usr/include/osmium/builder/osm_object_builder.hpp:36,
                 from /usr/include/osmium/io/detail/o5m_input_format.hpp:36,
                 from /usr/include/osmium/io/o5m_input.hpp:42,
                 from /usr/include/osmium/io/any_input.hpp:48,
                 from osm.cc:1:
/usr/include/osmium/osm/entity.hpp: In instantiation of ‘TSubitem& osmium::detail::subitem_of_type(TIter, const TIter&) [with TSubitem = const osmium::ChangesetDiscussion; TIter = osmium::memory::CollectionIterator<const osmium::memory::Item>]’:
/usr/include/osmium/osm/changeset.hpp:434:95:   required from here
/usr/include/osmium/osm/entity.hpp:54:29: error: use of deleted function ‘osmium::memory::Collection<osmium::ChangesetComment, osmium::item_type::changeset_discussion>::Collection(osmium::memory::Collection<osmium::ChangesetComment, osmium::item_type::changeset_discussion>&&)’
   54 |             static TSubitem subitem{};
      |                             ^~~~~~~
/usr/include/osmium/osm/entity.hpp: In instantiation of ‘TSubitem& osmium::detail::subitem_of_type(TIter, const TIter&) [with TSubitem = osmium::RelationMemberList; TIter = osmium::memory::CollectionIterator<osmium::memory::Item>]’:
/usr/include/osmium/osm/relation.hpp:188:86:   required from here
/usr/include/osmium/osm/entity.hpp:54:29: error: use of deleted function ‘osmium::memory::Collection<osmium::RelationMember, osmium::item_type::relation_member_list>::Collection(osmium::memory::Collection<osmium::RelationMember, osmium::item_type::relation_member_list>&&)’
In file included from /usr/include/osmium/osm/area.hpp:36,
                 from /usr/include/osmium/builder/osm_object_builder.hpp:38,
                 from /usr/include/osmium/io/detail/o5m_input_format.hpp:36,
                 from /usr/include/osmium/io/o5m_input.hpp:42,
                 from /usr/include/osmium/io/any_input.hpp:48,
                 from osm.cc:1:
/usr/include/osmium/memory/collection.hpp:117:15: note: ‘osmium::memory::Collection<osmium::RelationMember, osmium::item_type::relation_member_list>::Collection(osmium::memory::Collection<osmium::RelationMember, osmium::item_type::relation_member_list>&&)’ is implicitly deleted because the default definition would be ill-formed:
  117 |         class Collection : public Item {
      |               ^~~~~~~~~~
/usr/include/osmium/memory/collection.hpp:117:15: error: use of deleted function ‘osmium::memory::Item::Item(osmium::memory::Item&&)’
In file included from /usr/include/osmium/memory/buffer.hpp:36,
                 from /usr/include/osmium/builder/builder.hpp:36,
                 from /usr/include/osmium/builder/osm_object_builder.hpp:36,
                 from /usr/include/osmium/io/detail/o5m_input_format.hpp:36,
                 from /usr/include/osmium/io/o5m_input.hpp:42,
                 from /usr/include/osmium/io/any_input.hpp:48,
                 from osm.cc:1:
/usr/include/osmium/memory/item.hpp:146:13: note: declared here
  146 |             Item(Item&&) = delete;
      |             ^~~~
In file included from /usr/include/osmium/memory/buffer.hpp:38,
                 from /usr/include/osmium/builder/builder.hpp:36,
                 from /usr/include/osmium/builder/osm_object_builder.hpp:36,
                 from /usr/include/osmium/io/detail/o5m_input_format.hpp:36,
                 from /usr/include/osmium/io/o5m_input.hpp:42,
                 from /usr/include/osmium/io/any_input.hpp:48,
                 from osm.cc:1:
/usr/include/osmium/osm/entity.hpp: In instantiation of ‘TSubitem& osmium::detail::subitem_of_type(TIter, const TIter&) [with TSubitem = const osmium::RelationMemberList; TIter = osmium::memory::CollectionIterator<const osmium::memory::Item>]’:
/usr/include/osmium/osm/relation.hpp:193:94:   required from here
/usr/include/osmium/osm/entity.hpp:54:29: error: use of deleted function ‘osmium::memory::Collection<osmium::RelationMember, osmium::item_type::relation_member_list>::Collection(osmium::memory::Collection<osmium::RelationMember, osmium::item_type::relation_member_list>&&)’
   54 |             static TSubitem subitem{};
      |                             ^~~~~~~

does this look like an issue in osmium? or is it a compiler bug I should report?

@tomhughes
Copy link
Contributor Author

I can't see any reason why a declaration of a static TSubitem (which is actually a TagList) would need to use it's move constructor, which appears to be what the compiler is suggesting here so my money is on a compiler bug...

@tomhughes
Copy link
Contributor Author

tomhughes commented Jan 12, 2021

A minimal reproducer:

class base {
public:
  base(void) {};
  base(base &&) = delete;
};

class foo : public base {
};

template<typename C>
inline C &bar(void)
{
  static C c{};
  return c;
}

const foo &baz(void)
{
  return bar<const foo>();
}

which fails:

bug.cpp: In instantiation of ‘C& bar() [with C = const foo]’:
bug.cpp:21:25:   required from here
bug.cpp:15:12: error: use of deleted function ‘base::base(base&&)’
   15 |   static C c{};
      |            ^
bug.cpp:5:3: note: declared here
    5 |   base(base &&) = delete;
      |   ^~~~

@joto
Copy link
Member

joto commented Jan 12, 2021

You could try this with different C++ version settings. Maybe the new GCC uses a new compiler version by default and there is some issue with that.

@tomhughes
Copy link
Contributor Author

Good point - it works with std=c++14 but not with std=c++17.

I've assigned the RedHat bug which started this to the compilter team so hopefully they will either say it's a compiler bug or tell us what libosmium is doing wrong ;-)

@tomhughes
Copy link
Contributor Author

Both gcc 10 and clang 11 are happy though, even in c++17 mode.

@tomhughes
Copy link
Contributor Author

There's a gcc bug now (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98642) so I think we can close this.

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

No branches or pull requests

2 participants