Commit a20bda6179b41c0cf49d557b0b21c3fb4f6c09b7
1 parent
97a4d551
Fix GCC version check for null deref
Fixes #288.
Showing
1 changed file
with
7 additions
and
7 deletions
include/cxxopts.hpp
| @@ -70,6 +70,10 @@ THE SOFTWARE. | @@ -70,6 +70,10 @@ THE SOFTWARE. | ||
| 70 | #define CXXOPTS__VERSION_MINOR 0 | 70 | #define CXXOPTS__VERSION_MINOR 0 |
| 71 | #define CXXOPTS__VERSION_PATCH 0 | 71 | #define CXXOPTS__VERSION_PATCH 0 |
| 72 | 72 | ||
| 73 | +#if (__GNUC__ < 10 || (__GNUC__ == 10 && __GNUC_MINOR__ < 1)) && __GNUC__ >= 6 | ||
| 74 | + #define CXXOPTS_NULL_DEREF_IGNORE | ||
| 75 | +#endif | ||
| 76 | + | ||
| 73 | namespace cxxopts | 77 | namespace cxxopts |
| 74 | { | 78 | { |
| 75 | static constexpr struct { | 79 | static constexpr struct { |
| @@ -1386,11 +1390,9 @@ namespace cxxopts | @@ -1386,11 +1390,9 @@ namespace cxxopts | ||
| 1386 | m_long_name = &details->long_name(); | 1390 | m_long_name = &details->long_name(); |
| 1387 | } | 1391 | } |
| 1388 | 1392 | ||
| 1389 | -#if defined(__GNUC__) | ||
| 1390 | -#if __GNUC__ <= 10 && __GNUC_MINOR__ <= 1 | 1393 | +#if defined(CXXOPTS_NULL_DEREF_IGNORE) |
| 1391 | #pragma GCC diagnostic push | 1394 | #pragma GCC diagnostic push |
| 1392 | -#pragma GCC diagnostic ignored "-Werror=null-dereference" | ||
| 1393 | -#endif | 1395 | +#pragma GCC diagnostic ignored "-Wnull-dereference" |
| 1394 | #endif | 1396 | #endif |
| 1395 | 1397 | ||
| 1396 | CXXOPTS_NODISCARD | 1398 | CXXOPTS_NODISCARD |
| @@ -1400,11 +1402,9 @@ namespace cxxopts | @@ -1400,11 +1402,9 @@ namespace cxxopts | ||
| 1400 | return m_count; | 1402 | return m_count; |
| 1401 | } | 1403 | } |
| 1402 | 1404 | ||
| 1403 | -#if defined(__GNUC__) | ||
| 1404 | -#if __GNUC__ <= 10 && __GNUC_MINOR__ <= 1 | 1405 | +#if defined(CXXOPTS_NULL_DEREF_IGNORE) |
| 1405 | #pragma GCC diagnostic pop | 1406 | #pragma GCC diagnostic pop |
| 1406 | #endif | 1407 | #endif |
| 1407 | -#endif | ||
| 1408 | 1408 | ||
| 1409 | // TODO: maybe default options should count towards the number of arguments | 1409 | // TODO: maybe default options should count towards the number of arguments |
| 1410 | CXXOPTS_NODISCARD | 1410 | CXXOPTS_NODISCARD |