This is the mail archive of the gcc@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]

Re: gcc 2.95.2 problem


Is it legal to have a default value in a definition?

int ff (const C &a,  fp predicate = C::f) { .. }

Maybe you could try it like this instead?

extern int ff (const C &a,  fp predicate = C::f);
int ff (const C &a,  fp predicate ) { .. }

Brian Beuning


Piotr Nestorow wrote:

> Hi,
>
> On Linux (RedHat 6.1) with g++:
>
> Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/specs
> gcc version 2.95.2 19991024 (release)
>
> I get a strange error:
>
> t.cc:10: sorry, not implemented: initializer contains unrecognized tree code
> t.cc:10: default argument `C::f' uses local variable ` /* decl error */ '
>
> How can this be fixed? In the code, in the compiler ...
>
> Regards
> Piotr Nestorow
> Telelogic AB, Sweden
> Piotr.Nestorow@telelogic.se
>
> The example t.cc:
> -----------------
>
> typedef bool (*fp)(wchar_t);
>
> class C {
> public:
>   static bool f(wchar_t);
>   static bool f(char c);
> };
>
> int ff (const C &a,  fp predicate = C::f)
> {
>  return 2;
> }
>
> bool C::f(wchar_t)
> {
>  return 1;
> }
>
> int main(void) {
>   C c;
>   ff(c);
>   return 0;
> }


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