diff --git a/include/yaml-cpp/emitter.h b/include/yaml-cpp/emitter.h index 6f142b011..2add9ee07 100644 --- a/include/yaml-cpp/emitter.h +++ b/include/yaml-cpp/emitter.h @@ -164,13 +164,12 @@ inline Emitter& Emitter::WriteStreamable(T value) { std::isnan(value)) { special = true; stream << ".nan"; - } else if (std::numeric_limits::has_infinity) { - if (value == std::numeric_limits::infinity()) { - special = true; - stream << ".inf"; - } else if (value == -std::numeric_limits::infinity()) { - special = true; + } else if (std::numeric_limits::has_infinity && std::isinf(value)) { + special = true; + if (std::signbit(value)) { stream << "-.inf"; + } else { + stream << ".inf"; } } } diff --git a/include/yaml-cpp/node/detail/impl.h b/include/yaml-cpp/node/detail/impl.h index 46615a9f4..a776d752c 100644 --- a/include/yaml-cpp/node/detail/impl.h +++ b/include/yaml-cpp/node/detail/impl.h @@ -115,6 +115,7 @@ inline node* node_data::get(const Key& key, return pNode; return NULL; case NodeType::Scalar: + default: throw BadSubscript(key); } @@ -143,6 +144,7 @@ inline node& node_data::get(const Key& key, shared_memory_holder pMemory) { convert_to_map(pMemory); break; case NodeType::Scalar: + default: throw BadSubscript(key); } diff --git a/include/yaml-cpp/node/detail/node_iterator.h b/include/yaml-cpp/node/detail/node_iterator.h index 088090fe7..11768f7ec 100644 --- a/include/yaml-cpp/node/detail/node_iterator.h +++ b/include/yaml-cpp/node/detail/node_iterator.h @@ -111,6 +111,8 @@ class node_iterator_base return m_seqIt == rhs.m_seqIt; case iterator_type::Map: return m_mapIt == rhs.m_mapIt; + default: + break; } return true; } @@ -131,6 +133,8 @@ class node_iterator_base ++m_mapIt; m_mapIt = increment_until_defined(m_mapIt); break; + default: + break; } return *this; } @@ -149,6 +153,8 @@ class node_iterator_base return value_type(**m_seqIt); case iterator_type::Map: return value_type(*m_mapIt->first, *m_mapIt->second); + default: + break; } return value_type(); }