Please vote: C++ compiler bug - destructor called twice

I

Ioannis Vranos

Carl said:
Is this a simplification of the problem you posted a couple days ago with
the subject "compiler bug", or is this a new issue?


What's going on with this voting system anyway? Myself have submitted a
bug of VC++ 2005 Express Beta 1. If it is not voted by someone else, it
will not be fixed?
 
C

Carl Daniel [VC++ MVP]

Ioannis said:
What's going on with this voting system anyway? Myself have submitted
a bug of VC++ 2005 Express Beta 1. If it is not voted by someone
else, it will not be fixed?

Not at all. Bugs with more votes are more likely to be acted on sooner,
that's all.

-cd
 
G

Guest

It's a simplification. The old code didn't go through the voting system
probably because of another bug. The problem is even worse than I thought
before. I am just unable to use mixed managed/unmanaged code, especially
with another bug with wcschr(). Who knows how many other bugs are there!

I wonder whether it's possible to get a hotfix from Microsoft? They don't
seem to want to fix VC7.1. I am pretty sure 8.0 will contain a lot of new
bugs, and it's at least a half of a year away.


// Compile with "cl /clr bug.cpp"

#include <iostream>
using namespace std;

struct A
{
A() { cout << "A() " << this << endl; }
A( const A& ) { cout << "A(A) " << this << endl; }
~A() { cout << "~A() " << this << endl; }

};

#pragma unmanaged // Comment out to fix the problem

void foo( A o ) { cout << "foo" << endl; }

#pragma managed

void main()
{
cout << "Before foo" << endl;
foo( A() ); cout << "After foo" << endl;
}

Results:

Before foo
A() 0012F584
~A() 0012F584
foo
~A() 0012F500
After foo
 
R

Ronald Laeremans [MSFT]

The best guidance I can give for 7.0 and 7.1 is to not pass by value any c++
objects with construction and destruction semantics that aren't idempotent
through an IJW interop boundary.

We are fixing this (it isn't in any current drop yet) for Whidbey. There is
absolutely no way to fix it for earlier versions since it requires changes
in the C++ compiler, the metadata and the CLR interop layer.

Ronald Laeremans
Visual C++ team
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top