Skip to content

Commit

Permalink
Fix error: default initialization of an object of const type
Browse files Browse the repository at this point in the history
This commit fixes a regression introduced in a3e5b54 (Problem: Socket
options lack type-safety (zeromq#393)).

It addresses the following error reported when building the project
on macOS 10.11.6.

Errors like the following:

  cppzmq/zmq.hpp:1325:39: error: default initialization of an object of const type 'const affinity_t' (aka 'const integral_option<4, unsigned long long, false>') without a user-provided default constructor

Compiler version:

  Apple LLVM version 8.0.0 (clang-800.0.42.1)
  Target: x86_64-apple-darwin15.6.0
  Thread model: posix
  InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Similar issues:

 * tensorflow/tensorflow#28839
  error: default initialization of an object of const type 'const Subgraph::Identity' without a user-provided default constructor

 * https://bugzilla.mozilla.org/show_bug.cgi?id=1451088
   Clang 3.8: error: default initialization of an object of const type 'const js::jit::ArithPolicy' without a user-provided default constructor

 * googleapis/google-cloud-cpp#1593
   [osx] error: default initialization of an object of const type

Co-authored-by: Gudmundur Adalsteinsson <[email protected]>
  • Loading branch information
jcfr and gummif committed May 5, 2020
1 parent 3746e5c commit 5e28623
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions zmq.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1296,19 +1296,19 @@ template<int Opt, int NullTerm = 1> struct array_option

#define ZMQ_DEFINE_INTEGRAL_OPT(OPT, NAME, TYPE) \
using NAME##_t = integral_option<OPT, TYPE, false>; \
ZMQ_INLINE_VAR ZMQ_CONSTEXPR_VAR NAME##_t NAME
ZMQ_INLINE_VAR ZMQ_CONSTEXPR_VAR NAME##_t NAME{}
#define ZMQ_DEFINE_INTEGRAL_BOOL_UNIT_OPT(OPT, NAME, TYPE) \
using NAME##_t = integral_option<OPT, TYPE, true>; \
ZMQ_INLINE_VAR ZMQ_CONSTEXPR_VAR NAME##_t NAME
ZMQ_INLINE_VAR ZMQ_CONSTEXPR_VAR NAME##_t NAME{}
#define ZMQ_DEFINE_ARRAY_OPT(OPT, NAME) \
using NAME##_t = array_option<OPT>; \
ZMQ_INLINE_VAR ZMQ_CONSTEXPR_VAR NAME##_t NAME
ZMQ_INLINE_VAR ZMQ_CONSTEXPR_VAR NAME##_t NAME{}
#define ZMQ_DEFINE_ARRAY_OPT_BINARY(OPT, NAME) \
using NAME##_t = array_option<OPT, 0>; \
ZMQ_INLINE_VAR ZMQ_CONSTEXPR_VAR NAME##_t NAME
ZMQ_INLINE_VAR ZMQ_CONSTEXPR_VAR NAME##_t NAME{}
#define ZMQ_DEFINE_ARRAY_OPT_BIN_OR_Z85(OPT, NAME) \
using NAME##_t = array_option<OPT, 2>; \
ZMQ_INLINE_VAR ZMQ_CONSTEXPR_VAR NAME##_t NAME
ZMQ_INLINE_VAR ZMQ_CONSTEXPR_VAR NAME##_t NAME{}

// duplicate definition from libzmq 4.3.3
#if defined _WIN32
Expand Down

0 comments on commit 5e28623

Please sign in to comment.