Skip to content

Commit

Permalink
exprtk: attempt to avoid mingw -Werror=null-dereference
Browse files Browse the repository at this point in the history
  • Loading branch information
dbaston committed Dec 2, 2024
1 parent 1ba078c commit 36c0665
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion third_party/exprtk/exprtk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21302,7 +21302,7 @@ namespace exprtk
inline bool valid() const
{
// Symbol table sanity check.
return control_block_ && control_block_->data_;
return (control_block_ != nullptr) && (control_block_->data_ != nullptr);
}

inline void load_from(const symbol_table<T>& st)
Expand Down

4 comments on commit 36c0665

@rouault
Copy link
Member

@rouault rouault commented on 36c0665 Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dbaston I strongly doubt this will ave any effect. -Werror=null-dereference has a number of false positives. I'd suggest you wrap the inclusion of exprtk.hpp with

#if defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnull-dereference"
#endif

#include "exprtk.hpp"

#if defined(__GNUC__)
#pragma GCC diagnostic pop
#endif

@dbaston
Copy link
Member Author

@dbaston dbaston commented on 36c0665 Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will try that next. I can't figure out why the warning is even enabled in the first place, given that it's added as a system header which disables warnings on all other platforms that we test.

https://github.com/OSGeo/gdal/pull/11209/files#diff-8efe41fec01001c2b54615fb45c5cd18865448b5be850a221afffe171c94e1fdR27

@rouault
Copy link
Member

@rouault rouault commented on 36c0665 Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given that it's added as a system header which disables warnings on all other platforms that we test.

you mean using bracketed include #include <exprtk.hpp> ? I don't think that disables gcc warning per se. In a number of situations where I didn't manage to shut off warnings, I create a thin include file with a #pragma GCC system_header before the actual include. Like https://github.com/OSGeo/gdal/blob/master/port/include_fast_float.h

@dbaston
Copy link
Member Author

@dbaston dbaston commented on 36c0665 Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean using bracketed include #include <exprtk.hpp> ?

I mean that that directory is flagged as a system directory in CMake:

target_include_directories(gdal_vrt SYSTEM PRIVATE ${PROJECT_SOURCE_DIR}/third_party/exprtk)

It removed all of the exprtk warnings on other platforms, and every warning except this one on mingw.

Please sign in to comment.