J
JKop
The following compiles for me with G++:
const unsigned int z(5U);
unsigned int y(5 + 6 - 4 / 2 + 3 * 6 - z);
inline unsigned int x()
{
return y * 4 + z - 9 * 3;
}
inline unsigned int w()
{
unsigned int temp( ( x() > 8 ? x() + 5 : x() - 4 ) );
temp -= 4;
temp *= 5;
return temp + 6;
}
unsigned int v(unsigned int input)
{
if ( input > 16 )
{
return input + w();
}
else
{
return input - x();
}
}
#include <iostream>
using std::cout;
using std::endl;
int main()
{
char a[z];
y += 4;
char b[y];
char c[x()];
char d[w()];
char e[v(w())];
cout << sizeof(a) << endl
<< sizeof(b) << endl
<< sizeof(c) << endl
<< sizeof(d) << endl
<< sizeof(e);
}
I'm wondering if this is guaranteed to compile on every C++ Standard
compliant compiler. The values are indeed "knowable" at compile time, but it
seems to me that a compiler has a bit of work to do.
It prints the following for me:
5
26
82
421
842
Anyone else want to give it a try?
-JKop
const unsigned int z(5U);
unsigned int y(5 + 6 - 4 / 2 + 3 * 6 - z);
inline unsigned int x()
{
return y * 4 + z - 9 * 3;
}
inline unsigned int w()
{
unsigned int temp( ( x() > 8 ? x() + 5 : x() - 4 ) );
temp -= 4;
temp *= 5;
return temp + 6;
}
unsigned int v(unsigned int input)
{
if ( input > 16 )
{
return input + w();
}
else
{
return input - x();
}
}
#include <iostream>
using std::cout;
using std::endl;
int main()
{
char a[z];
y += 4;
char b[y];
char c[x()];
char d[w()];
char e[v(w())];
cout << sizeof(a) << endl
<< sizeof(b) << endl
<< sizeof(c) << endl
<< sizeof(d) << endl
<< sizeof(e);
}
I'm wondering if this is guaranteed to compile on every C++ Standard
compliant compiler. The values are indeed "knowable" at compile time, but it
seems to me that a compiler has a bit of work to do.
It prints the following for me:
5
26
82
421
842
Anyone else want to give it a try?
-JKop