diff --git a/cmake/unix_compiler_options.cmake b/cmake/unix_compiler_options.cmake index 40ca72cb14..f8445f25d1 100644 --- a/cmake/unix_compiler_options.cmake +++ b/cmake/unix_compiler_options.cmake @@ -24,7 +24,6 @@ function(pdal_target_compile_settings target) ${PDAL_CXX_STANDARD} -Wall -Wextra - -Wpedantic -Wpointer-arith -Wcast-align -Wcast-qual diff --git a/filters/AssignFilter.cpp b/filters/AssignFilter.cpp index 24e790d11d..33640d73ac 100644 --- a/filters/AssignFilter.cpp +++ b/filters/AssignFilter.cpp @@ -95,7 +95,7 @@ std::istream& operator>>(std::istream& in, AssignRange& r) { r.parse(s); } - catch (DimRange::error) + catch (DimRange::error&) { in.setstate(std::ios_base::failbit); } diff --git a/io/LasHeader.cpp b/io/LasHeader.cpp index a95667e815..d0199bd183 100644 --- a/io/LasHeader.cpp +++ b/io/LasHeader.cpp @@ -218,7 +218,7 @@ void LasHeader::setSrs() else setSrsFromGeotiff(); } - catch (Geotiff::error err) + catch (Geotiff::error& err) { m_log->get(LogLevel::Error) << "Could not create an SRS: " << err.what() << std::endl; diff --git a/io/PlyReader.cpp b/io/PlyReader.cpp index 3d76fda9a5..5d68f761cc 100644 --- a/io/PlyReader.cpp +++ b/io/PlyReader.cpp @@ -172,7 +172,7 @@ Dimension::Type PlyReader::getType(const std::string& name) { return types.at(name); } - catch (std::out_of_range) + catch (std::out_of_range&) {} return Dimension::Type::None; } diff --git a/io/PlyWriter.cpp b/io/PlyWriter.cpp index c730526a30..949726c3ff 100644 --- a/io/PlyWriter.cpp +++ b/io/PlyWriter.cpp @@ -109,7 +109,7 @@ std::string PlyWriter::getType(Dimension::Type type) const { return types.at(type); } - catch (std::out_of_range) + catch (std::out_of_range&) { throwError("Can't write dimension of type '" + Dimension::interpretationName(type) + "'."); diff --git a/kernels/TIndexKernel.cpp b/kernels/TIndexKernel.cpp index 194a8d14ff..614369f6e8 100644 --- a/kernels/TIndexKernel.cpp +++ b/kernels/TIndexKernel.cpp @@ -393,7 +393,7 @@ void TIndexKernel::mergeFile() options.add("offset_z", "auto"); writer.addOptions(options); } - catch (std::bad_cast) + catch (std::bad_cast&) {} PointTable table; @@ -457,7 +457,7 @@ bool TIndexKernel::createFeature(const FieldIndexes& indexes, { err = OSRExportToProj4(srcSrs.get(), &pszProj4); } - catch (pdal_error) + catch (pdal_error&) {} if (err != OGRERR_NONE) { diff --git a/pdal/Kernel.cpp b/pdal/Kernel.cpp index 292637509e..8b36d57da1 100644 --- a/pdal/Kernel.cpp +++ b/pdal/Kernel.cpp @@ -264,7 +264,7 @@ int Kernel::innerRun(ProgramArgs& args) // do any user-level sanity checking validateSwitches(args); } - catch (pdal_error e) + catch (pdal_error& e) { Utils::printError(e.what()); outputHelp(args); diff --git a/pdal/Metadata.cpp b/pdal/Metadata.cpp index ad5bcc847d..f810e9dfb4 100644 --- a/pdal/Metadata.cpp +++ b/pdal/Metadata.cpp @@ -56,7 +56,7 @@ std::string Metadata::inferType(const std::string& val) pos = 0; l = std::stol(val, &pos); } - catch (std::invalid_argument) + catch (std::invalid_argument&) {} if (pos == val.length()) return (l < 0 ? "nonNegativeInteger" : "integer"); @@ -66,7 +66,7 @@ std::string Metadata::inferType(const std::string& val) pos = 0; std::stod(val, &pos); } - catch(std::invalid_argument) + catch(std::invalid_argument&) {} if (pos == val.length()) diff --git a/pdal/Metadata.hpp b/pdal/Metadata.hpp index e504d9d0b0..9c261f4a15 100644 --- a/pdal/Metadata.hpp +++ b/pdal/Metadata.hpp @@ -349,6 +349,34 @@ inline void MetadataNodeImpl::setValue(const Uuid& u) m_value = u.toString(); } +namespace MetadataDetail +{ + +class value_error +{}; + +template +T value(const std::string& type, const std::string& value) +{ + T t{}; + + if (type == "base64Binary") + { + std::vector encVal = Utils::base64_decode(value); + encVal.resize(sizeof(T)); + memcpy(&t, encVal.data(), sizeof(T)); + } + else if (!Utils::fromString(value, t)) + throw value_error(); + return t; +} + +template<> +inline std::string value(const std::string&, const std::string& value) +{ return value; } + +} // namespace MetadataDetail + class PDAL_DLL MetadataNode { @@ -483,30 +511,25 @@ class PDAL_DLL MetadataNode { T t{}; - if (m_impl->m_type == "base64Binary") + try { - std::vector encVal = - Utils::base64_decode(m_impl->m_value); - encVal.resize(sizeof(T)); - memcpy(&t, encVal.data(), sizeof(T)); + t = MetadataDetail::value(m_impl->m_type, m_impl->m_value); } - else + catch (MetadataDetail::value_error&) { - if (!Utils::fromString(m_impl->m_value, t)) - { - // Static to get default initialization. - static T t2; - std::cerr << "Error converting metadata [" << name() << - "] = " << m_impl->m_value << " to type " << - Utils::typeidName() << " -- return default initialized."; - t = t2; - } + // Reset in case the fromString conversion messed it up. + t = T(); + std::cerr << "Error converting metadata [" << name() << + "] = " << m_impl->m_value << " to type " << + Utils::typeidName() << " -- return default initialized."; } return t; } std::string value() const - { return m_impl->m_value; } + { + return value(); + } std::string jsonValue() const { @@ -712,7 +735,6 @@ class Metadata }; typedef std::shared_ptr MetadataPtr; - } // namespace pdal diff --git a/pdal/PDALUtils.cpp b/pdal/PDALUtils.cpp index 63b23b9f69..d5043551fd 100644 --- a/pdal/PDALUtils.cpp +++ b/pdal/PDALUtils.cpp @@ -272,7 +272,7 @@ std::ostream *createFile(const std::string& path, bool asBinary) ofs = new ArbiterOutStream(tempFilename(path), path, asBinary ? ios::out | ios::binary : ios::out); } - catch (arbiter::ArbiterError) + catch (arbiter::ArbiterError&) {} if (ofs && !ofs->good()) { @@ -305,7 +305,7 @@ std::istream *openFile(const std::string& path, bool asBinary) return new ArbiterInStream(tempFilename(path), path, asBinary ? ios::in | ios::binary : ios::in); } - catch (arbiter::ArbiterError) + catch (arbiter::ArbiterError&) { return nullptr; } diff --git a/pdal/pdal_types.hpp b/pdal/pdal_types.hpp index e7d9f53538..70ce411af6 100644 --- a/pdal/pdal_types.hpp +++ b/pdal/pdal_types.hpp @@ -182,7 +182,7 @@ inline std::istream& operator>>(std::istream& in, LogLevel& level) if (val >= 0 && val < (int)logNames.size()) level = (LogLevel)val; } - catch (std::exception) + catch (std::exception&) { sval = Utils::tolower(sval); for (size_t i = 0; i < logNames.size(); ++i) diff --git a/pdal/util/FileUtils.cpp b/pdal/util/FileUtils.cpp index 7679f22698..7ca17e3bc6 100644 --- a/pdal/util/FileUtils.cpp +++ b/pdal/util/FileUtils.cpp @@ -154,7 +154,7 @@ std::vector directoryList(const std::string& dir) it++; } } - catch (pdalboost::filesystem::filesystem_error) + catch (pdalboost::filesystem::filesystem_error&) { files.clear(); } @@ -213,7 +213,7 @@ bool fileExists(const std::string& name) { return pdalboost::filesystem::exists(name); } - catch (pdalboost::filesystem::filesystem_error) + catch (pdalboost::filesystem::filesystem_error&) { } return false; diff --git a/pdal/util/Utils.hpp b/pdal/util/Utils.hpp index c5621a4631..f0530a73c2 100644 --- a/pdal/util/Utils.hpp +++ b/pdal/util/Utils.hpp @@ -941,7 +941,7 @@ namespace Utils return true; } } - catch (std::invalid_argument) // Character that isn't a number? + catch (std::invalid_argument&) // Character that isn't a number? { if (s.length() == 1) { @@ -973,7 +973,7 @@ namespace Utils return true; } } - catch (std::invalid_argument) // Character that isn't a number? + catch (std::invalid_argument&) // Character that isn't a number? { if (s.length() == 1) { @@ -1005,7 +1005,7 @@ namespace Utils return true; } } - catch (std::invalid_argument) // Character that isn't a number? + catch (std::invalid_argument&) // Character that isn't a number? { if (s.length() == 1) { diff --git a/vendor/arbiter/arbiter.cpp b/vendor/arbiter/arbiter.cpp index 357a69b5c5..84457915ec 100644 --- a/vendor/arbiter/arbiter.cpp +++ b/vendor/arbiter/arbiter.cpp @@ -2032,7 +2032,7 @@ std::vector S3::glob(std::string path, bool verbose) const { xml.parse<0>(data.data()); } - catch (Xml::parse_error) + catch (Xml::parse_error&) { throw ArbiterError("Could not parse S3 response."); } diff --git a/vendor/kazhdan/Array.h b/vendor/kazhdan/Array.h index e46e7681cc..0cdab0b43e 100644 --- a/vendor/kazhdan/Array.h +++ b/vendor/kazhdan/Array.h @@ -96,7 +96,11 @@ template< class C > ConstArray< C > GetPointer( const C* c , int sz ) { return C #define DeletePointer( ... ) { if( __VA_ARGS__ ) delete[] __VA_ARGS__ , __VA_ARGS__ = NULL; } template< class C > C* NewPointer( size_t size , const char* name=NULL ){ return new C[size]; } -template< class C > C* AllocPointer( size_t size , const char* name=NULL ){ return (C*) malloc( sizeof(C) * size ); } +template< class C > +C* AllocPointer(size_t size, const char* name = NULL) +{ + return (C*) calloc(size, sizeof(C)); +} template< class C > C* AlignedAllocPointer( size_t size , size_t alignment , const char* name=NULL ){ return (C*)aligned_malloc( sizeof(C) * size , alignment ); } template< class C > C* ReAllocPointer( C* c , size_t size , const char* name=NULL ){ return (C*) realloc( c , sizeof(C) * size ); } diff --git a/vendor/kazhdan/MultiGridOctreeData.System.inl b/vendor/kazhdan/MultiGridOctreeData.System.inl index 7052ca09f8..0cce269385 100644 --- a/vendor/kazhdan/MultiGridOctreeData.System.inl +++ b/vendor/kazhdan/MultiGridOctreeData.System.inl @@ -1910,7 +1910,6 @@ void Octree< Real >::_addFEMConstraints( const FEMConstraintFunctor& F , const C delete __constraints; DenseNodeData< D > _coefficients( _sNodesEnd(maxDepth-1) ); - memset( &_coefficients[0] , 0 , sizeof(D) * _sNodesEnd(maxDepth-1) ); for( LocalDepth d=maxDepth-1 ; d>=0 ; d-- ) { #pragma omp parallel for num_threads( threads ) diff --git a/vendor/kazhdan/MultiGridOctreeData.h b/vendor/kazhdan/MultiGridOctreeData.h index 6f56ee6e5e..8fa0552427 100644 --- a/vendor/kazhdan/MultiGridOctreeData.h +++ b/vendor/kazhdan/MultiGridOctreeData.h @@ -326,7 +326,14 @@ template< class Data > struct DenseNodeData { DenseNodeData( void ){ _data = NullPointer( Data ) ; _sz = 0; } - DenseNodeData( size_t sz ){ _sz = sz ; if( sz ) _data = NewPointer< Data >( sz ) ; else _data = NullPointer( Data ); } + DenseNodeData( size_t sz ) + { + _sz = sz ; + if ( sz ) + _data = NewPointer< Data >( sz ); + else + _data = NullPointer( Data ); + } DenseNodeData( const DenseNodeData& d ) : DenseNodeData() { _resize( d._sz ) ; if( _sz ) memcpy( _data , d._data , sizeof(Data) * _sz ); } DenseNodeData( DenseNodeData&& d ){ _data = d._data , _sz = d._sz ; d._data = NullPointer( Data ) , d._sz = 0; } DenseNodeData& operator = ( const DenseNodeData& d ){ _resize( d._sz ) ; if( _sz ) memcpy( _data , d._data , sizeof(Data) * _sz ) ; return *this; } diff --git a/vendor/kazhdan/MultiGridOctreeData.inl b/vendor/kazhdan/MultiGridOctreeData.inl index c9a22ef023..de39ac83c6 100644 --- a/vendor/kazhdan/MultiGridOctreeData.inl +++ b/vendor/kazhdan/MultiGridOctreeData.inl @@ -242,7 +242,7 @@ int Octree< Real >::init(PointSource& source , LocalDepth maxDepth , if (!colorSource.nextPoint(_p, _d)) break; } - catch (std::bad_cast) + catch (std::bad_cast&) { if (!source.nextPoint(_p)) break; diff --git a/vendor/kazhdan/PPolynomial.inl b/vendor/kazhdan/PPolynomial.inl index f90cc5c840..8b5d6dd0fb 100644 --- a/vendor/kazhdan/PPolynomial.inl +++ b/vendor/kazhdan/PPolynomial.inl @@ -115,10 +115,7 @@ void PPolynomial::set( size_t size ) FreePointer( polys ); polyCount = size; if( size ) - { polys = AllocPointer< StartingPolynomial< Degree > >( size ); - memset( polys , 0 , sizeof( StartingPolynomial< Degree > )*size ); - } } template< int Degree > void PPolynomial::reset( size_t newSize ) diff --git a/vendor/kazhdan/PoissonRecon.h b/vendor/kazhdan/PoissonRecon.h index e1e8687e03..06259b3968 100644 --- a/vendor/kazhdan/PoissonRecon.h +++ b/vendor/kazhdan/PoissonRecon.h @@ -372,7 +372,7 @@ int loadOctTree(Octree& tree, XForm4x4& xForm, PointSource& source, return tree.template init< Point3D< Real >>(xsource, depth, confidence, *samples, sampleData); } - catch (std::bad_cast) + catch (std::bad_cast&) {} TransformedPointSource xsource(xForm, source); diff --git a/vendor/pdalboost/boost/mpl/assert.hpp b/vendor/pdalboost/boost/mpl/assert.hpp index 12b882d6ae..dcf4935a98 100644 --- a/vendor/pdalboost/boost/mpl/assert.hpp +++ b/vendor/pdalboost/boost/mpl/assert.hpp @@ -184,6 +184,8 @@ template< typename P > struct assert_arg_pred_not typedef typename assert_arg_pred_impl

::type type; }; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wparentheses" template< typename Pred > failed ************ (Pred::************ assert_arg( void (*)(Pred), typename assert_arg_pred::type ) @@ -193,6 +195,7 @@ template< typename Pred > failed ************ (pdalboost::mpl::not_::************ assert_not_arg( void (*)(Pred), typename assert_arg_pred_not::type ) ); +#pragma GCC diagnostic pop template< typename Pred > AUX778076_ASSERT_ARG(assert)