This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/396: const int null = 0;
- From: Wolfgang Bangerth <bangerth at ticam dot utexas dot edu>
- To: gcc-bugs at gcc dot gnu dot org, <gcc-gnats at gcc dot gnu dot org>
- Date: Tue, 22 Oct 2002 17:40:47 -0500 (CDT)
- Subject: Re: c++/396: const int null = 0;
I don't actually know what the standard would mandate in this case
(conversion from 'const int &' to 'int *'), but this is clearly at least
confusing (stripped down and condensed testcase from this report):
-----------------------------------
void f(int* pn);
struct Foo {
static void f(int* pn);
};
int main() {
const int null = 0;
f(0); // ok
f(null); // ok
Foo::f(0); // ok
Foo::f(null); // compile error
}
----------------------------------
The compiler only gives an error on the call to Foo::f(), not on ::f(),
although they have the same signature. For present CVS and 3.2, the error
message is
x.cc: In function `int main()':
x.cc:14: error: invalid conversion from `int' to `int*'
x.cc:14: error: initializing argument 1 of `static void Foo::f(int*)'
Regards
Wolfgang
-------------------------------------------------------------------------
Wolfgang Bangerth email: bangerth@ticam.utexas.edu
www: http://www.ticam.utexas.edu/~bangerth