<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">The fix is pretty much ready and David
H. has reviewed it.<br>
I'll need one more review before the fix can be checked in.<br>
<br>
Calvin<br>
p.s. I was on vacation last week.<br>
<br>
On 6/3/2013 3:57 PM, Jeremy Manson wrote:<br>
</div>
<blockquote
cite="mid:CAPYFHW34s4AJHFsApYcaUCKxEwqWAEX8XbidhemDc59VHzsPeA@mail.gmail.com"
type="cite">
<div dir="ltr">I can't really argue with you there! What's the
status of this review, anyway?</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">On Mon, Jun 3, 2013 at 12:04 AM, David
Holmes <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:david.holmes@oracle.com" target="_blank">david.holmes@oracle.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 30/05/2013 5:28 AM, Jeremy Manson wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">
On Thu, May 23, 2013 at 5:56 PM, David Holmes <<a
moz-do-not-send="true"
href="mailto:david.holmes@oracle.com" target="_blank">david.holmes@oracle.com</a><br>
</div>
<mailto:<a moz-do-not-send="true"
href="mailto:david.holmes@oracle.com" target="_blank">david.holmes@oracle.com</a>>>
wrote:<br>
<br>
src/share/vm/utilities/__taskqueue.hpp
<div class="im"><br>
<br>
I do not understand this code:<br>
<br>
! // g++ complains if the volatile result of
the assignment<br>
is unused.<br>
</div>
! const_cast<E&>(_elems[__localBot]
= t);
<div class="im"><br>
<br>
why do we even need the const cast? How is
the assignment<br>
not used ???<br>
<br>
I've tried without the const cast and got the
following error:<br>
</div>
/scratch/cccheung/hs25/src/__share/vm/utilities/taskqueue.__hpp:348:
<div class="im"><br>
error:<br>
object of type ‘volatile StarTask&’ will not
be accessed in<br>
statement<br>
<br>
There was an original comment about the const
cast as follows:<br>
343 // g++ complains if the volatile result of
the assignment is<br>
unused.<br>
</div>
344 const_cast<E&>(_elems[__localBot] =
t);
<div class="im"><br>
<br>
<br>
Yep I already quoted that comment above :) And I
still don't<br>
understand it. What variable is a "volatile E&"?
_elems is a<br>
"volatile E*" so I guess _elems[i] is a "volatile
E&" but we are<br>
assigning it, so how can it not be used ??? I wonder
if the problem<br>
is that "t" is a plain E not a "volatile E&"?
But then I also wonder<br>
whether _elems was meant to be declared as "E *
volatile" ?<br>
<br>
Anyway your current fix is fine.<br>
<br>
<br>
<br>
I was away on vacation last week, so I didn't
participate in this<br>
thread. Since most of the fixes here were mine, I
should probably<br>
comment. The "cast the volatile away" is because of the
last sentence<br>
in this doc:<br>
<br>
<a moz-do-not-send="true"
href="http://gcc.gnu.org/onlinedocs/gcc-4.0.4/gcc/Volatiles.html"
target="_blank">http://gcc.gnu.org/onlinedocs/gcc-4.0.4/gcc/Volatiles.html</a><br>
<br>
The value returned by the assignment statement counts as
a read of a<br>
const volatile variable. Since the const volatile read
is unused, g++<br>
complains. The answer is to cast the value to an rvalue
(in this case,<br>
the original programmer chose to cast away the const).<br>
</div>
</blockquote>
<br>
Thanks for the pointer. This seems like sheer silliness on
the part of gcc:<br>
<br>
_elems[i];<br>
<br>
should issue a warning<br>
<br>
_elems[i] = t;<br>
<br>
should not.<span class="HOEnZb"><font color="#888888"><br>
<br>
David</font></span>
<div class="HOEnZb">
<div class="h5"><br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
This is all well and good, but now we have a
const_cast whose value is<br>
unused, so we have to cast it to void.<br>
<br>
We can't cast directly to void because void isn't an
rvalue.<br>
<br>
I couldn't fit that entire explanation in the comment.
It might be<br>
worth someone else having a crack at it.<br>
<br>
And it is very possible that the logic is wrong. I
didn't look<br>
carefully at it, but relying on volatile in C++-not-11
to do anything<br>
other than ensure that writes to mmap regions all
happen is probably a<br>
bad idea.<br>
<br>
Jeremy<br>
<br>
-<br>
</blockquote>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
</body>
</html>