N
Norman J. Goldstein
The following program compiles and links.
No warnings The output is wrong, stating:
value= 1
value NOT 1
//////////////////////////////////////////////
#include <iostream>
using namespace std;
static constexpr int value = 1;
int main( int argc, char* argv[] )
{
cout << "value= "
<< value
<< endl;
static_assert( value == 1, "Value_Not_1" );
#if value == 1
cout << "value 1" << endl;
#else
cout << "value NOT 1" << endl;
#endif
return 0;
}// main
/////////////////////////////////////////////////
Why is value not used in the conditional compilation?
(The static_assert is happy.)
I am using
gcc version 4.7.2 20121109 (Red Hat 4.7.2-8) (GCC)
pn
Linux 3.9.11-200.fc18.i686.PAE #1 SMP
No warnings The output is wrong, stating:
value= 1
value NOT 1
//////////////////////////////////////////////
#include <iostream>
using namespace std;
static constexpr int value = 1;
int main( int argc, char* argv[] )
{
cout << "value= "
<< value
<< endl;
static_assert( value == 1, "Value_Not_1" );
#if value == 1
cout << "value 1" << endl;
#else
cout << "value NOT 1" << endl;
#endif
return 0;
}// main
/////////////////////////////////////////////////
Why is value not used in the conditional compilation?
(The static_assert is happy.)
I am using
gcc version 4.7.2 20121109 (Red Hat 4.7.2-8) (GCC)
pn
Linux 3.9.11-200.fc18.i686.PAE #1 SMP