Bug? Return value of type bool returns always true?

  • Thread starter Thread starter Gernold Schneider
  • Start date Start date
G

Gernold Schneider

I have a managed code function calling a unmanaged code
function which returns a "bool". Obviously the return value
is always "true", if i am not running the code in the debugger.

If i run the code in the debugger, everything works fine.

Is this a known bug?

Example:

#pragma unmanaged
bool function_unmanaged( void ) {
return false;
}
#pragma managed

bool function( void ) {
return function_unmanaged(); // returns true !!!
}
 
Gernold said:
I have a managed code function calling a unmanaged code
function which returns a "bool". Obviously the return value
is always "true", if i am not running the code in the debugger.

If i run the code in the debugger, everything works fine.

Is this a known bug?

Example:

#pragma unmanaged
bool function_unmanaged( void ) {
return false;
}
#pragma managed

bool function( void ) {
return function_unmanaged(); // returns true !!!
}

IIRC, this is a known bug, but at the moment I can't seem to find any
reference to point you towards.

-cd
 
Hi, Gernold. I'm having trouble cooking up a simple test case that
reproduces the problem you describe when I build it with the VS .Net 2003
tools. Can you tell me which version of the tools you're using, and can you
share a minimal code segment that reproduces the problem on your machine?

Thanks very much.

--
Paul Leathers, Microsoft Visual C++ Team
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples is subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
--------------------
 
Paul said:
Hi, Gernold. I'm having trouble cooking up a simple test case that
reproduces the problem you describe when I build it with the VS .Net
2003 tools. Can you tell me which version of the tools you're using,
and can you share a minimal code segment that reproduces the problem
on your machine?

As Carl said: IT IS A KNOWN BUG FOR OVER 1 YEAR now!!!

I reported it 12.04.2002.

See also:
http://groups.google.de/groups?threadm=#b7FOgiRDHA.2020%
40TK2MSFTNGP11.phx.gbl

I reported it 12.04.2002 !!!
MS-Support-ID: SRD020412600033

Here is the code to reproduce the problem:

<code>
#using <mscorlib.dll>
#include <tchar.h>

using namespace System;

// The following is unmanaged code (it can also be a library)
#pragma unmanaged
class Unmanaged
{
public:
virtual bool AreYouOk();
};

bool Unmanaged::AreYouOk()
{
// It returns always true!!! even if I specify false!!!!
return false;
}

// the following is managed code
#pragma managed


// This is the entry point for this application
int _tmain(void)
{
Unmanaged *um = new Unmanaged();
if (um->AreYouOk() == true)
Console::WriteLine(S"The bug is STILL THERE!!!!!!!");
else
Console::WriteLine(S"Everything Ok...");

return 0;
}
</code>

--
Greetings
Jochen

Do you need a memory-leak finder ?
http://www.codeproject.com/useritems/leakfinder.asp
 
Paul said:
Hi, Gernold. I'm having trouble cooking up a simple test case that
reproduces the problem you describe when I build it with the VS .Net
2003 tools. Can you tell me which version of the tools you're using,
and can you share a minimal code segment that reproduces the problem
on your machine?

Thanks very much.

Paul -

Jeff Peil confirmed to be that this bug is known and will be fixed in a
future release.

-cd
 
Hi, Gernold. I'm having trouble cooking up a simple test case that
reproduces the problem you describe when I build it with the VS .Net 2003
tools. Can you tell me which version of the tools you're using, and can you
share a minimal code segment that reproduces the problem on your machine?

Versions:
MS Dev. Env. 2003 Version 7.1.3088
MS .NET Framework Version 1.1.4322
I can't find the C++ compiler version.

The important points to reproduce the bug are:

1. The called function has to be a virtual member function.
2. The called function has to be unmanaged.
3. Return type has to be "bool".
4. The caller has to be managed.

If You are not able to create a simple test case, I could provide You
with the original source code wherein I encountered this bug.
(The code snippet provided by Jochen Kalmbach is very similar to my
code, so it should reproduce the bug.)

Gernold
 
Back
Top