ETLCPP / etl

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

fix c++20-compat false positive #909

Open jaskij opened 3 days ago

jaskij commented 3 days ago

Fix #906

semanticdiff-com[bot] commented 3 days ago

Review changes with SemanticDiff.

jaskij commented 3 days 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 3 days ago

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

jwellbelove commented 3 days 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 3 days 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 3 days ago

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