egcs 970828 : Explicit call of a constructor
Klaus-Georg Adams
Klaus-Georg.Adams@chemie.uni-karlsruhe.de
Wed Sep 3 02:24:00 GMT 1997
> This is a multi-part message in MIME format.
> --------------44AE6A709DBC265F79C097B8
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
>
> For reasons which are too long to explain here, I need to reconstruct
> the virtual table of objects.
>
> To do it, with gcc 2.7.2, I am doing an axplicit call to a specific
> constructor. So I write the following code :
>
> BX_Connection::CM_RebuildOBJ(CM_Restart *rsq)
> {
> BX_Connection *obj = this;
> obj->BX_Connection::BX_Connection(rsq);
> }
>
> This is not beautifull, but it works wonderfull !
>
> But ... When I compile this code with egcs, I've got a parse error
> before '('.
>
> There is nothing about this in C++ draft. What is Cygnus position about
> it ? Can we consider it as a egcs' bug ?
No, it's a bug in your program.
If you have to do a hack like that you should use the placement new
syntax:
void* operator new( unsigned int, void* p ) { return p; }
struct CM_Restart;
struct BX_Connection {
BX_Connection( CM_Restart* );
void CM_RebuildOBJ( CM_Restart * );
};
void
BX_Connection::CM_RebuildOBJ(CM_Restart *rsq)
{
new (this) BX_Connection(rsq);
}
-- kga
-------------------------------------------------------------------------
Klaus-Georg Adams Email: Klaus-Georg.Adams@chemie.uni-karlsruhe.de
Institut f. Anorg. Chemie II Tel: 0721 608 3485
Uni Karlsruhe
-------------------------------------------------------------------------
More information about the Gcc-bugs
mailing list