Skip to content

context::ContextValue cannot be compiled with Visual Studio 2015 #314

@maxgolov

Description

@maxgolov

ContextValue has been recently introduced in SDK. Unfortunately the two nostd::shared_ptr<...> variant members are failing to compile with Visual Studio 2015, due to issue in nostd::variant backport.

This code fails to compile:

using ContextValue = nostd::variant<bool,
                                    int64_t,
                                    uint64_t,
                                    double,
                                    nostd::shared_ptr<trace::Span>,
                                    nostd::shared_ptr<trace::SpanContext>>;

with the following error:

1>c:\work\opentelemetry-cpp\api\include\opentelemetry\nostd\variant.h(168): error C2672: 'opentelemetry::v0::nostd::detail::visitation::base::make_farray': no matching overloaded function found
1>c:\work\opentelemetry-cpp\api\include\opentelemetry\nostd\variant.h(173): note: see reference to class template instantiation 'opentelemetry::v0::nostd::detail::visitation::base::make_fmatrix_impl<F,opentelemetry::v0::nostd::detail::base<opentelemetry::v0::nostd::detail::Trait::Available,bool,int64_t,uint64_t,double,opentelemetry::v0::nostd::shared_ptr<opentelemetry::v0::trace::Span>,opentelemetry::v0::nostd::shared_ptr<opentelemetry::v0::trace::SpanContext>> &>::impl<opentelemetry::v0::nostd::integer_sequence<std::size_t>,opentelemetry::v0::nostd::integer_sequence<std::size_t>>' being compiled

whereas a simpler definition of the variant that does not use nostd::shared_ptr - compiles successfully:

using ContextValue = nostd::variant < bool, int64_t, uint64_t, double>;

The issue is in a way how nostd::variant backport handles complex objects. Primitive types are OK.

There could be a few alternative solutions to this issue:

  • declare that we cannot support Visual Studio 2015
  • declare that RuntimeContext API does not work with Visual Studio 2015
  • simplify the implementation to avoid positioning complex objects on variant, possibly using raw pointers instead
  • fix an issue in implementation of nostd::detail::visitation::base
  • explore ability to substitute the nostd::variant with absl::variant ( somewhat related to [WIP] Ability to use Standard Library as a substitute for nostd:: classes #275 - ability to substitute nostd with alternate implementation )

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingpriority:p1Issues that are blocking

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions