T.R | Title | User | Personal Name | Date | Lines |
---|
3561.1 | | DECC::OUELLETTE | mudseason into blackfly season | Tue May 06 1997 12:40 | 2 |
| Write a copy constructor in addition to a default constructor.
See what happens...
|
3561.2 | | ANNECY::LAROCHE_P | Ne Suze que si l'on Sancerre | Wed May 07 1997 05:11 | 4 |
| I added a copy constructor to my class, but nothing changed.
Thanks anyway,
Pierre
|
3561.3 | more objects than you think? | HNDYMN::MCCARTHY | A Quinn Martin Production | Wed May 07 1997 06:56 | 3 |
| how many times was the copy ctor called?
bjm
|
3561.4 | Copy constructor NOT called | ANNECY::LAROCHE_P | Ne Suze que si l'on Sancerre | Wed May 07 1997 07:02 | 10 |
| The copy constructor is NOT called (message couted does not appear).
For information, the copy constructor I added is:
CDummy (const CDummy &dummy)
{
cout << "CDummy object (" << this << ") copy constructor called" << endl;
};
Pierre
|
3561.5 | | DECC::OUELLETTE | mudseason into blackfly season | Wed May 07 1997 13:02 | 72 |
| Now I see I was confused. The pthreads thing uses setjmp to implement
C++ exception handling... After preprocessing main looks a bit like:
void main ()
{
__pthreadExcCtx_t __exc_ctx__;
__exc_ctx__.__sentinel = 0x45586732;
__exc_ctx__.__version = 2;
pthread_exc_push_ctx_np (&__exc_ctx__);
if (!setjmp ((__pthreadExcLong_t *)(__exc_ctx__.__jmp))) {
CDummy aDummy;
__pthreadExcCtx_t __exc_ctx__;
__exc_ctx__.__sentinel = 0x45586732;
__exc_ctx__.__version = 2;
pthread_exc_push_ctx_np (&__exc_ctx__);
if (!setjmp ((__pthreadExcLong_t *)(__exc_ctx__.__jmp))) {
pthread_exc_raise_np(&(pthread_cancel_e));
} else {
__pthreadExceptionObj_t *PTHREAD_THIS_CATCH_NP =
(__pthreadExceptionObj_t *)&__exc_ctx__.__cur_exception;
__exc_ctx__.__exc_state = _PTHREAD_EXC_STATE_HANDLED;
cerr << "Inner PTHREAD exception caught" << endl;
}
if ((__exc_ctx__.__exc_state == _PTHREAD_EXC_STATE_NONE) ||
(__exc_ctx__.__exc_state == _PTHREAD_EXC_STATE_ACTIVE))
pthread_exc_pop_ctx_np (&__exc_ctx__);
} else {
__pthreadExceptionObj_t *PTHREAD_THIS_CATCH_NP =
(__pthreadExceptionObj_t *)&__exc_ctx__.__cur_exception;
__exc_ctx__.__exc_state = _PTHREAD_EXC_STATE_HANDLED;
cerr << "Outer PTHREAD exception caught" << endl;
}
if ((__exc_ctx__.__exc_state == _PTHREAD_EXC_STATE_NONE) ||
(__exc_ctx__.__exc_state == _PTHREAD_EXC_STATE_ACTIVE))
pthread_exc_pop_ctx_np (&__exc_ctx__);
}
Well I'm not really sure what's up, but after poking around
it appears that the flow control hidden by the setjmp has baffled
things a bit. The problem seems to be that you've not turned off
C++ exception handling, so things may be being handled twice.
In any case compiling the program without C++ EH cleanup blocks
seems to work...
cosf> cxx cxx3561.cxx -nocleanup -lpthread
cosf> a.out
CDummy object (0x11fffef98) constructor called
Inner PTHREAD exception caught
CDummy object (0x11fffef98) destructor called
cosf>
Perhaps there's a bug in the documentation or perhaps the driver
should use -nocleanup when -pthreads is on...
cosf> cxx cxx3561.cxx -pthread
cosf> a.out
CDummy object (0x11fffef98) constructor called
CDummy object (0x11fffef98) destructor called
Inner PTHREAD exception caught
CDummy object (0x11fffef98) destructor called
cosf> cxx cxx3561.cxx -pthread -nocleanup
cosf> a.out
CDummy object (0x11fffef98) constructor called
Inner PTHREAD exception caught
CDummy object (0x11fffef98) destructor called
cosf>
I'd be inclined to call it a driver bug.
You have a workaround. Charlie can decide what the problem is
and make an entry in our bug tracking system... this is his week.
R.
|
3561.6 | | DECC::KAO | | Sun May 11 1997 13:56 | 59 |
| Since DECthread implements its own exception handling by using setjmp,
I tried to simulate the case (in .5) but failed.
My example works fine (See below). so if you could provide some information
about these routines (e.g. pthread_exc_push_ctx_np, pthread_exc_pop_ctx_np,
pthread_exc_raise_np, pthread_cancel_e) or their specs, we'll be happy to look
it more.
/* cpp3561b.cxx */
#include "setjmp.h"
extern jmp_buf myjmpbuf;
void raise_longjmp() {
longjmp(myjmpbuf,0);
return;
}
/* cpp3561a.cxx */
#include "setjmp.h"
extern "C" {extern int printf(const char *, ...);}
//
// Dummy class
//
jmp_buf myjmpbuf;
class CDummy
{
public:
CDummy () { printf("CDummy constructor called. %0x\n",this);}
~CDummy () { printf("CDummy distructor called. %0x\n",this);}
};
extern void raise_longjmp();
void main ()
{
if (!setjmp(myjmpbuf)) {
CDummy aDummy;
if (!setjmp(myjmpbuf)) {
raise_longjmp();
} else {
printf("Inner PTHREAD exception caught.\n");
}
} else {
printf("Outer PTHREAD exception caught.\n");
}
}
shijun.zko.dec.com> $CEXE/deccxx_driver cpp3561a.cxx cpp3561b.cxx
cpp3561a.cxx:
cpp3561b.cxx:
shijunom> a.out
CDummy constructor called. 1fffefc0
Inner PTHREAD exception caught.
CDummy distructor called. 1fffefc0
|
3561.7 | Replied at clt::cma 1539.4 | DECC::KAO | | Tue May 13 1997 14:16 | 2 |
| This topic is discussed at clt::cma 1539.
I'll move it back to here when later becomes necessary.
|