Skip to content
This repository has been archived by the owner on Apr 17, 2019. It is now read-only.

Commit

Permalink
Add default constructor for LazyInitalizer
Browse files Browse the repository at this point in the history
This prevents initialization bug from old versions of gcc (pre 7.2)

Signed-off-by: Nikita Alekseev <n.alekseev2104@gmail.com>

# Conflicts:
#	test/benchmark/CMakeLists.txt
#	test/benchmark/bm_proto_creation.cpp
  • Loading branch information
nickaleks committed Jul 9, 2018
1 parent e29672b commit e389a49
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class NonCopyableProto : public Iface {
using TransportType = Proto;

template <typename Transport>
NonCopyableProto(Transport &&ref) : proto_(std::forward<Transport>(ref)){};
NonCopyableProto(Transport &&ref) : proto_(std::forward<Transport>(ref)){}

const Proto &getTransport() const {
return proto_;
Expand Down
17 changes: 17 additions & 0 deletions shared_model/utils/lazy_initializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,23 @@ namespace shared_model {
using GeneratorType = std::function<Target()>;

public:
/**
* Default constructor prevents compilation error in pre 7.2 gcc.
*
* Short explanation: gcc needs default constructor
* when the constructor is inherited (via using Base::Base)
* if the inherited class has default initalizers for any of its members.
* This can be found in shared_model/backend/protobuf/protobuf/block.hpp
* where Lazy fields are initialized via default initializers.
*
* Note that this does not result in default constructor being called, so
* the resulting code is still correct. This is an issue of gcc compiler
* which is resolved in 7.2
*
* For more details: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67054
*/
LazyInitializer();

template <typename T>
explicit LazyInitializer(T &&generator)
: generator_(std::forward<T>(generator)) {}
Expand Down

0 comments on commit e389a49

Please sign in to comment.