I recently ran across this problem... My code looks like this.
#define SomeFloat 0.5
static const int SomeIntConst = ((int)(SomeFloat + 0.5));
template<int V>
struct SomeStruct
{
};
int main()
{
SomeStruct<SomeIntConst> ();
return 0;
}
When I compile this with ICC, or GCC, or Microsoft Visual C++,
with default settings, it compiles properly.
Even with GCC -ansi, it compiles properly.
However, when I compile it with GCC's -pedantic option, I get
the following error messages:
tmp.cc:11: error: 'SomeIntConst' cannot appear in a constant-expression
tmp.cc:11: error: template argument 1 is invalid
What is the right behavior in this situation for a compiler to do?
--
Joel Yliluoma - http://iki.fi/bisqwit/
[ See http://www.gotw.ca/resources/clcm.htm
for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]