🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Stephen Ng Tue, 11 Apr 1989 14:33
g++ bugs
#1852
Author: Stephen Ng
Date: Tue, 11 Apr 1989 14:33
58 lines
1686 bytes
Hi, I've just tried porting over a large number of files from cfront to g++. 
I'm using g++ 1.34.0. Here are two of the problems I found:

1) Description:  g++ doesn't implicitly cast between fundamental types if the
return value of a member function is a reference which is immediately used as an
argument for another function.

Example:

char &ref_return();

class c
{
        public:
                int_arg(int i);
};

void foo()
{
        c c1;
        c1.int_arg(ref_return());
}
works in cfront, but produces "bad argument 0 for function 'c::int_arg (int)'
(type was char &)

Workaround:
Assign the return value to a temporary variable and use the temporary as the
function argument.

2) Description:  g++ doesn't initialize by assignment for a class if the class
a) has no constructor explicitly declared and b) if the class has a member class
 which has a constructor.

Example:
                
class Member {
public:
        Member();
};

class Foo {
        Member mem;
};

void func()
{
        Foo f1;
        Foo f2 = f1;
}

This passes through cfront properly, but generates a "unexpected argument to
constructor 'Foo'" error in g++.
Workaround: 
        explicitly declare a constructor for class Foo.

Thanks,

Steve
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads