using g ++ and compiling with -Waggregate-return
#define DOCTEST_CHECK(expr) \ do { \ _Pragma("GCC diagnostic push"); \ _Pragma("GCC diagnostic ignored \"-Waggregate-return\"");\ if(Result failed = (ExpressionDecomposer() << expr)) \ printf("%s\n", failed.m_decomposition.c_str()); \ _Pragma("GCC diagnostic pop"); \ } while(false) DOCTEST_CHECK(true == false); // produces warnings
but the manually deployed version does not generate any warnings:
do { _Pragma("GCC diagnostic push"); _Pragma("GCC diagnostic ignored \"-Waggregate-return\""); if(Result failed = (ExpressionDecomposer() << true == false)) printf("%s\n", failed.m_decomposition.c_str()); _Pragma("GCC diagnostic pop"); } while(false);
Should the behavior be the same?
I don't think the Result
and ExpressionDecomposer
types matter - just classes.
I am trying to get a decomposition expression that works like this (things have been renamed).
EDIT: β here <is a live demonstration of the problem using the lest library
My question is why? how can I be a warning for free in the first case using a macro? I cannot afford to silence a warning globally.
source share