Yes, fully agree to Joergs interpretation.
Nikolai
Joerg Barfurth wrote:
I'd however like to establish a rule that classes/functions taking a
pointer to (possibly) not fully constructed classes have a comment that
explicitely allows that - assuming that everywhere else it is a bug.
Is a
Mathias Bauer schrieb:
Nikolai Pretzell wrote:
I'd however like to establish a rule that classes/functions taking a
pointer to (possibly) not fully constructed classes have a comment that
explicitely allows that - assuming that everywhere else it is a bug.
Is a cast to the base class when
Hi,
just to make clear, if it wasn't yet obvious:
Joerg Barfurth wrote:
So one could argue, fixing the warning does not necessarily fix the
problem, so we can remove the warning anyway.
Right. The warning (with warnings=errors) forces us to use a workaround,
which may even have a negative
Nikolai Pretzell wrote:
I'd however like to establish a rule that classes/functions taking a
pointer to (possibly) not fully constructed classes have a comment that
explicitely allows that - assuming that everywhere else it is a bug.
Is a cast to the base class when passing this enough?
Hi,
I've got a long hate relationship with this warning, because it kept
popping up and never showed a real problem in my code. Some more
objective arguments against can be found inline.
Nikolai Pretzell wrote:
warning:
test.cxx(18) : warning C4355: 'this' : used in base member
Nikolai Pretzell wrote:
Hi Carsten and all,
warning:
test.cxx(18) : warning C4355: 'this' : used in base member initializer
list
class A
{
public:
A() {}
};
class B
{
A _a;
public:
B( A a ) : _a(a) {}
};
class C : public A
{
B _b;
public:
C() : _b( *(A*)this ) {}
};
I don't understand the not look too safe example:
Class B will never be able to call a virtual method which is implemented
in C. Not within the CTOR.
And when talking about Dialogs:
Moving member initialization with 'this' to the body is not easily done.
You must change all Window members to
Hi Carsten and all,
warning:
test.cxx(18) : warning C4355: 'this' : used in base member initializer list
class A
{
public:
A() {}
};
class B
{
A _a;
public:
B( A a ) : _a(a) {}
};
class C : public A
{
B _b;
public:
C() : _b( *(A*)this ) {}
};
int main()
{
C c;
}
Hi all,
With the MS C++ compiler and our current warning settings, the following
code example produces the warning:
test.cxx(18) : warning C4355: 'this' : used in base member initializer list
class A
{
public:
A() {}
};
class B
{
A _a;
public:
B( A a ) : _a(a) {}
};
class C :