Connecting Tech Pros Worldwide Help | Site Map

strange ???

  #1  
Old March 14th, 2006, 06:15 PM
kathy
Guest
 
Posts: n/a
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

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

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

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).


Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hi...about some strange character in textfile blumen answers 14 September 5th, 2007 09:09 AM
Need a strange sort method... SpreadTooThin answers 20 October 17th, 2006 05:45 PM
perhaps a stack problem? Long calculations - strange error? Martin Joergensen answers 11 May 10th, 2006 04:26 AM
Strange Exception Specification Behaviour Paul Drummond answers 2 July 23rd, 2005 06:06 AM
Strange XML nesting and schema validation Arthur answers 2 July 20th, 2005 09:17 AM