This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Support for compiling with clang++ >= 3.9.1 #7702
Copy link
Copy link
Closed
Description
We currently hit errors due to warnings with clang++ 3.9.1. This is because the enum.hpp header emits a warning with -Wundefined-var-template which is newly added to clang++ and enabled by default: http://llvm.org/viewvc/llvm-project?view=revision&revision=266719.
@kkaefer @jfirebaugh - any ideas to work around? Or should we suppress?
../../../include/mbgl/util/enum.hpp:17:32: error: instantiation of variable 'mbgl::Enum<mbgl::style::SymbolPlacementType>::begin' required here, but no definition is available [-Werror,-Wundefined-var-template]
auto it = std::find_if(begin, end, [&] (const auto& v) { return t == v.first; });
^
../../../src/mbgl/style/conversion/stringify.hpp:52:28: note: in instantiation of member function 'mbgl::Enum<mbgl::style::SymbolPlacementType>::toString' requested here
writer.String(Enum<T>::toString(v));
^
../../../src/mbgl/style/conversion/stringify.hpp:236:39: note: in instantiation of function template specialization 'mbgl::style::conversion::stringify<rapidjson::Writer<rapidjson::GenericStringBuffer<rapidjson::UTF8<char>, rapidjson::CrtAllocator>, rapidjson::UTF8<char>, rapidjson::UTF8<char>, rapidjson::CrtAllocator, 0>, mbgl::style::SymbolPlacementType, void>' requested here
v.evaluate([&] (const auto& v_) { stringify(writer, v_); });
^
../../../mason_packages/headers/variant/1.1.4/include/mapbox/variant.hpp:304:51: note: in instantiation of member function 'mapbox::util::detail::dispatcher<const (lambda at ../../../src/mbgl/style/conversion/stringify.hpp:236:16) &, mapbox::util::variant<mbgl::style::Undefined, mbgl::style::SymbolPlacementType, mbgl::style::Function<mbgl::style::SymbolPlacementType> >, void, mbgl::style::SymbolPlacementType, mbgl::style::Function<mbgl::style::SymbolPlacementType> >::apply_const' requested here
return dispatcher<F, V, R, Types...>::apply_const(v, std::forward<F>(f));
^
../../../mason_packages/headers/variant/1.1.4/include/mapbox/variant.hpp:850:55: note: in instantiation of member function 'mapbox::util::detail::dispatcher<const (lambda at ../../../src/mbgl/style/conversion/stringify.hpp:236:16) &, mapbox::util::variant<mbgl::style::Undefined, mbgl::style::SymbolPlacementType, mbgl::style::Function<mbgl::style::SymbolPlacementType> >, void, mbgl::style::Undefined, mbgl::style::SymbolPlacementType, mbgl::style::Function<mbgl::style::SymbolPlacementType> >::apply_const' requested here
return detail::dispatcher<F, V, R, Types...>::apply_const(v, std::forward<F>(f));
^
../../../include/mbgl/style/property_value.hpp:44:23: note: in instantiation of function template specialization 'mapbox::util::variant<mbgl::style::Undefined, mbgl::style::SymbolPlacementType, mbgl::style::Function<mbgl::style::SymbolPlacementType> >::visit<const (lambda at ../../../src/mbgl/style/conversion/stringify.hpp:236:16) &, mapbox::util::variant<mbgl::style::Undefined, mbgl::style::SymbolPlacementType, mbgl::style::Function<mbgl::style::SymbolPlacementType> >, void>' requested here
return Value::visit(value, evaluator);
^
../../../src/mbgl/style/conversion/stringify.hpp:243:9: note: in instantiation of function template specialization 'mbgl::style::conversion::stringify<rapidjson::Writer<rapidjson::GenericStringBuffer<rapidjson::UTF8<char>, rapidjson::CrtAllocator>, rapidjson::UTF8<char>, rapidjson::UTF8<char>, rapidjson::CrtAllocator, 0>, mbgl::style::SymbolPlacementType>' requested here
stringify(writer, value);
^
../../../src/mbgl/style/conversion/stringify.hpp:250:21: note: in instantiation of function template specialization 'mbgl::style::conversion::stringify<mbgl::style::SymbolPlacement, rapidjson::Writer<rapidjson::GenericStringBuffer<rapidjson::UTF8<char>, rapidjson::CrtAllocator>, rapidjson::UTF8<char>, rapidjson::UTF8<char>, rapidjson::CrtAllocator, 0>, mbgl::style::SymbolPlacementType>' requested here
util::ignore({ (stringify<Ps>(writer, ps.unevaluated.template get<Ps>()), 0)... });
^
Activity
springmeyer commentedon Jan 12, 2017
A second issue needing addressed to support clang >= 3.9.1 is this failure in the tests:
springmeyer commentedon Jan 12, 2017
The
no matching constructor for initializationis replicable on OS X and may be a clang 3.9.x bug. I can replicate with 3.9.0 and 3.9.1 and not 3.8.1 or 4.0.0 (head) with:springmeyer commentedon Jan 12, 2017
I found that:
Works around the compile error (and produces the right polygon still). Perhaps this is our bug and clang++ 3.9 is being more strict? Or could this be compiler bug...
springmeyer commentedon Jan 12, 2017
429016b works around the polygon ctor issue.
jfirebaugh commentedon Jan 17, 2017
I can't find any documentation of
-Wundefined-var-template, only discussion in the code review implementing it and in a prior attempt at implementing it. This seems to be the issue that led to someone adding it.As far as I can tell from the discussion, our code is valid, falling under the "uncommon, but an idiom used by some" category discussed in the second link, which suggests a workaround:
This would mean (re-)introducing a
MBGL_DECLARE_ENUMmacro and using it in the appropriate header file corresponding to each use ofMBGL_DEFINE_ENUM. The definition would be something like: