This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]