473,804 Members | 3,462 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Bug? Return value of type bool returns always true?

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_unmana ged( void ) {
return false;
}
#pragma managed

bool function( void ) {
return function_unmana ged(); // returns true !!!
}
Nov 16 '05 #1
5 1872
Gernold Schneider wrote:
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_unmana ged( void ) {
return false;
}
#pragma managed

bool function( void ) {
return function_unmana ged(); // 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
Nov 16 '05 #2
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
--------------------
From: "Gernold Schneider" <gs************ ***@t-online.de>
Newsgroups: microsoft.publi c.dotnet.langua ges.vc
Subject: Re: Bug? Return value of type bool returns always true?
Date: Thu, 21 Aug 2003 15:19:52 +0200
Organization: T-Online
Lines: 6
Message-ID: <bi************ *@news.t-online.com>
References: <bh************ *@news.t-online.com> <#y************ **@TK2MSFTNGP12 .phx.gbl> Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: news.t-online.com 1061472005 01 15818 5K3eVv3bS4YnQm 030821 13:20:05 X-Complaints-To: us**********@t-online.de
X-ID: EkvX5wZOgeN3pPK lgg8A2su3JImByd gp8S4uQyk1mMPvf jfBMCkno0
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!new sfeed00.sul.t-online.de!newsm m0
0.sul.t-online.com!t-online.de!news. t-online.com!not-for-mail Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.vc:27445
X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.vc

I must add, that the problem occurs only when calling
virtual member functions with return type "bool".

The example is misleading, sorry.


Nov 16 '05 #3
Paul Leathers [VCPP MSFT] wrote:
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?threa...FOgiRDHA.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::AreY ouOk()
{
// 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::WriteL ine(S"The bug is STILL THERE!!!!!!!");
else
Console::WriteL ine(S"Everythin g Ok...");

return 0;
}
</code>

--
Greetings
Jochen

Do you need a memory-leak finder ?
http://www.codeproject.com/useritems/leakfinder.asp
Nov 16 '05 #4
Paul Leathers [VCPP MSFT] wrote:
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
Nov 16 '05 #5
> 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
Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4143
by: dpakpaul | last post by:
Hi, I have an XSD schema where I have attributes that are declared to contain non string values such as integers etc. Take for example, this declaration - <xs:attribute name="IsThisTrue" type="xs:boolean" /> Now, I want to write or modify an XML document using the DOM API (using C#) where this attribute will be given a boolean value. Then the resulting XML document will be validated against the schema
10
19160
by: Mark Jerde | last post by:
I'm trying to learn the very basics of using an unmanaged C++ DLL from C#. This morning I thought I was getting somewhere, successfully getting back the correct answers to a C++ " int SumArray(int ray, int count)" Now I'm having problems with C++ "return(false)" being True in C#. Here is the C# code. ========================= using System; using System.Runtime.InteropServices; //
11
2778
by: randomtalk | last post by:
hi, i have the following recursive function (simplified to demonstrate the problem): >>> def reTest(bool): .... result = .... if not bool: .... reTest(True) .... else: .... print "YAHHH" .... result =
40
3165
by: Mark P | last post by:
I'm implementing an algorithm and the computational flow is a somewhat deep. That is, fcn A makes many calls to fcn B which makes many calls to fcn C, and so on. The return value of the outermost fcn is a boolean and there are certain places within the inner functions where it may become apparent that the return value is false. In this case I'd like to halt the computation immediately and return false. My current approach is to have...
16
2615
by: DaTurk | last post by:
Hi, I have a c# application that needs to access c++ libraries, so it does this by using a managed layer of c++ CLI. Anyway, in the CLI function call, that calls the unmanaged function it expects a boolean return value, which it gets, but the value changes! I walked throuhg the code, and the unmanged code is returning false, but when I look at the variable in the managed code it's return value it true. Even after I initialized the...
13
2916
by: cppquester | last post by:
A colleague told me that there is a rule about good stype that a function in C++ should have only one point of return (ie. return statement). Otherwise there might be trouble. I never heard about it and doubt it. Anybody heard of it? What would be the advantage? Regards, Marc Example:
7
10329
by: Terry Olsen | last post by:
How do I get this to work? It always returns False, even though I can see "This is True!" in the debug window. Do I have to invoke functions differently than subs? Private Delegate Function IsLvItemCheckedDelegate(ByVal ClientID As Integer) As Boolean Private Function IsLvItemChecked(ByVal ClientID As Integer) As Boolean If lvServers.InvokeRequired = True Then lvServers.Invoke(New IsLvItemCheckedDelegate(AddressOf IsLvItemChecked),...
6
1836
by: exander77 | last post by:
I am quite new to c++, about half of a year. I juct wonder, why such code is not possible: int chlen(char * ar) { for(int i=0;ar||return i;i++); } In my opinion, it would be much "cuter" than this: int chlen(char * ar) {
4
10285
Markus
by: Markus | last post by:
I have a method that checks whether the passed argument is present in an array. The method needs to return a bool value. Take a look at said method: private bool IPExist(string IP) { // We need to check if the IP exists in the // IP array foreach (string x in IPs) { if (x == IP)
0
9711
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9591
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10343
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10331
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9166
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7631
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5667
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4306
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.