Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old March 14th, 2006, 06:15 PM
kathy
Guest
 
Posts: n/a
Default strange ???

I have a piece of code which is in a multithread program:

....
bool b,b1;
b1 = MyData.success;
//MyData is protected using Mutex, b1=true here by using Visual Studio
watch window
b = (b1 == true);//return false ??????
b = (true && b1);//return true
....

  #2  
Old March 14th, 2006, 06:35 PM
Ben Pope
Guest
 
Posts: n/a
Default Re: strange ???

kathy wrote:[color=blue]
> I have a piece of code which is in a multithread program:
>
> ...
> bool b,b1;
> b1 = MyData.success;
> //MyData is protected using Mutex, b1=true here by using Visual Studio
> watch window
> b = (b1 == true);//return false ??????
> b = (true && b1);//return true
> ...[/color]

We can't help you unless you post complete compilable code.
Unfortunately, if you do that, it'll be off topic.

Best bet is to ask in a newsgroup where multithreading on Windows is
topical, perhaps somewhere in the public.microsoft.* hierarchy.

Ben Pope
--
I'm not just a number. To many, I'm known as a string...
  #3  
Old March 14th, 2006, 06:45 PM
Victor Bazarov
Guest
 
Posts: n/a
Default Re: strange ???

kathy wrote:[color=blue]
> I have a piece of code which is in a multithread program:
>
> ...
> bool b,b1;
> b1 = MyData.success;[/color]

Are you sure it's not

b = MyData.success;

here?
[color=blue]
> //MyData is protected using Mutex, b1=true here by using Visual Studio
> watch window[/color]

What's "Mutex"? (A hint: it's not topical here)
[color=blue]
> b = (b1 == true);//return false ??????
> b = (true && b1);//return true
> ...
>[/color]

This is covered by FAQ 5.8, I think.

V
--
Please remove capital As from my address when replying by mail
  #4  
Old March 15th, 2006, 04:15 PM
Andrew Koenig
Guest
 
Posts: n/a
Default Re: strange ???

"kathy" <yqin_99@yahoo.com> wrote in message
news:1142359666.655481.100460@p10g2000cwp.googlegr oups.com...
[color=blue]
> bool b,b1;
> b1 = MyData.success;
> //MyData is protected using Mutex, b1=true here by using Visual Studio
> watch window
> b = (b1 == true);//return false ??????
> b = (true && b1);//return true[/color]

Without seeing all the code, it's impossible to know for sure...but could it
be that MyData.success was never initialized? It is possible for
uninitialized bool objects to take on values that are neither true nor false
(because undefined behavior really means undefined, when anything can
happen).


 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles