ETLCPP / etl

Embedded Template Library
https://www.etlcpp.com
MIT License
2.25k stars 393 forks source link

fix c++20-compat false positive #909

Closed jaskij closed 4 months ago

jaskij commented 5 months ago

Fix #906

semanticdiff-com[bot] commented 5 months ago

Review changes with SemanticDiff.

jaskij commented 5 months ago

Explaining the pragmas:

#pragma GCC diagnostic push         // store current diagnostics setup
#pragma GCC diagnostic ignored "-Wc++20-compat" // disable C++20 compat warning

// code goes here

#pragma GCC diagnostic pop          // resture previously stored diagnostic setup
jaskij commented 5 months ago

I went with the pragma approach because this is the only place which causes the error

jwellbelove commented 5 months ago

To control warnings so far I've created headers that enable and disable them. See example include/etl/private/diagnostic_array_bounds_push.h and include/etl/private/diagnostic_pop.h

jwellbelove commented 5 months ago

Example of use...

#include "etl/private/diagnostic_array_bounds_push.h"
      position1 = compare_text.find_last_not_of(STR('C'), 100);
      position2 = text.find_last_not_of(STR('C'), 100);

      CHECK_EQUAL(position1, position2);
#include "etl/private/diagnostic_pop.h"
jaskij commented 5 months ago

Thank you for pointing that out, moved the diagnostics to their own file.