K
Keith Degrace
VC++ 2003 fails to compile the following code. I figured it may just
be a bug in VC, so I tried with Comeau Online and I get a similar
result. Now I am wondering if I've perhaps encountered an oddity in
the C++ standard.
typedef int *IntPtr;
void foo(const IntPtr)
{
}
void bar(const int &value)
{
foo(&value);
}
VC++ reports:
error C2664: 'foo' : cannot convert parameter 1 from 'const int *__w64
' to 'const IntPtr'
Conversion loses qualifiers
Comeau reports:
"ComeauTest.c", line 9: error: argument of type "const int *" is
incompatible with parameter of type "IntPtr"
If I remove IntPtr, and change foo() to take a int * explicitly, it
compiles fine. If I remove the const, it compiles fine.
Any ideas?
be a bug in VC, so I tried with Comeau Online and I get a similar
result. Now I am wondering if I've perhaps encountered an oddity in
the C++ standard.
typedef int *IntPtr;
void foo(const IntPtr)
{
}
void bar(const int &value)
{
foo(&value);
}
VC++ reports:
error C2664: 'foo' : cannot convert parameter 1 from 'const int *__w64
' to 'const IntPtr'
Conversion loses qualifiers
Comeau reports:
"ComeauTest.c", line 9: error: argument of type "const int *" is
incompatible with parameter of type "IntPtr"
If I remove IntPtr, and change foo() to take a int * explicitly, it
compiles fine. If I remove the const, it compiles fine.
Any ideas?