etl icon indicating copy to clipboard operation
etl copied to clipboard

fix c++20-compat false positive

Open jaskij opened this issue 1 year ago • 6 comments

Fix #906

jaskij avatar Jun 27 '24 14:06 jaskij

Review changes with SemanticDiff.

semanticdiff-com[bot] avatar Jun 27 '24 14:06 semanticdiff-com[bot]

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 avatar Jun 27 '24 14:06 jaskij

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

jaskij avatar Jun 27 '24 14:06 jaskij

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 avatar Jun 27 '24 14:06 jwellbelove

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"

jwellbelove avatar Jun 27 '24 14:06 jwellbelove

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

jaskij avatar Jun 27 '24 14:06 jaskij