Diagnostic 279: controlling expression is constant

Diagnostic 279: controlling expression is constant

Thank you for your interest in this diagnostic message. We are still in the process of documenting this specific diagnostic.

Please let us know of your experience with this diagnostic message by posting a comment below. Your interest in this diagnostic will help us prioritize the order we document diagnostics.

For more complete information about compiler optimizations, see our Optimization Notice.

4 comments

Top
anonymous's picture

Actually, this is a problem on Linux as well.

If you have

assert(false && "this should never happen");

you get the warning.
On my platform (kubuntu 10), assert(x) essentially expands to

((x) ? 0 : __assert_fail (__STRING(x), __FILE__, __LINE__, __func__))

which means something is checking (x) without noticing that it actually came from an assertion.

The real problem here is that the warning is indeed very useful IF the expression (x) does not contain
only compile-time constants. In other words: look at what x is made of, if they're all compile-time constants
don't warn, otherwise warn.

Happy to be contacted personally on the email provided for further discussion, if you need more help.
Luca

anonymous's picture

Here is an example with visual studio 2010 command line,

#include <cassert>
int main()
{
assert(false && "This will generate an controlling expression is constant warning with Intel C++");
}

>main.cpp(5): warning #279: controlling expression is constant
1> assert(false && "This will generate an controlling expression is constant warning with Intel C++");
1> ^

Command Line : Visual Studio 2010 : (the trick is /W4)
/Zi /nologo /W4 /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /EHsc /RTC1 /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fp"x64Debugit1.pch" /Fa"x64Debug" /Fo"x64Debug" /Fd"x64Debugvc100.pdb"

Jennifer J. (Intel)'s picture

I used a chello.cpp to try the "assert()", but could not get the diagnostic to emit. I used /Od /D_DEBUG /DDEBUG t.cpp with icl 11.1 or 12.0. Can you show me a more complete test and cmd line?

Thanks!

anonymous's picture

This diagnostic shows up on statements like:

assert(!"this is the text which will get displayed if this dead code branch is hit");

or

assert(x < y || !"x should be less than y here because ...");

have not found a workaround.

Add a Comment

Have a technical question? Visit our forums. Have site or software product issues? Contact support.