Connecting Tech Pros Worldwide Forums | Help | Site Map

strange ???

kathy
Guest
 
Posts: n/a
#1: Mar 14 '06
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
....


Ben Pope
Guest
 
Posts: n/a
#2: Mar 14 '06

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...
Victor Bazarov
Guest
 
Posts: n/a
#3: Mar 14 '06

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
Andrew Koenig
Guest
 
Posts: n/a
#4: Mar 15 '06

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