1.1 --- a/src/share/vm/utilities/taskqueue.hpp Thu Jun 13 11:16:38 2013 -0700 1.2 +++ b/src/share/vm/utilities/taskqueue.hpp Thu Jun 13 22:02:40 2013 -0700 1.3 @@ -340,8 +340,12 @@ 1.4 if (dirty_n_elems == N - 1) { 1.5 // Actually means 0, so do the push. 1.6 uint localBot = _bottom; 1.7 - // g++ complains if the volatile result of the assignment is unused. 1.8 - const_cast<E&>(_elems[localBot] = t); 1.9 + // g++ complains if the volatile result of the assignment is 1.10 + // unused, so we cast the volatile away. We cannot cast directly 1.11 + // to void, because gcc treats that as not using the result of the 1.12 + // assignment. However, casting to E& means that we trigger an 1.13 + // unused-value warning. So, we cast the E& to void. 1.14 + (void)const_cast<E&>(_elems[localBot] = t); 1.15 OrderAccess::release_store(&_bottom, increment_index(localBot)); 1.16 TASKQUEUE_STATS_ONLY(stats.record_push()); 1.17 return true; 1.18 @@ -397,7 +401,12 @@ 1.19 return false; 1.20 } 1.21 1.22 - const_cast<E&>(t = _elems[oldAge.top()]); 1.23 + // g++ complains if the volatile result of the assignment is 1.24 + // unused, so we cast the volatile away. We cannot cast directly 1.25 + // to void, because gcc treats that as not using the result of the 1.26 + // assignment. However, casting to E& means that we trigger an 1.27 + // unused-value warning. So, we cast the E& to void. 1.28 + (void) const_cast<E&>(t = _elems[oldAge.top()]); 1.29 Age newAge(oldAge); 1.30 newAge.increment(); 1.31 Age resAge = _age.cmpxchg(newAge, oldAge); 1.32 @@ -640,8 +649,12 @@ 1.33 uint dirty_n_elems = dirty_size(localBot, top); 1.34 assert(dirty_n_elems < N, "n_elems out of range."); 1.35 if (dirty_n_elems < max_elems()) { 1.36 - // g++ complains if the volatile result of the assignment is unused. 1.37 - const_cast<E&>(_elems[localBot] = t); 1.38 + // g++ complains if the volatile result of the assignment is 1.39 + // unused, so we cast the volatile away. We cannot cast directly 1.40 + // to void, because gcc treats that as not using the result of the 1.41 + // assignment. However, casting to E& means that we trigger an 1.42 + // unused-value warning. So, we cast the E& to void. 1.43 + (void) const_cast<E&>(_elems[localBot] = t); 1.44 OrderAccess::release_store(&_bottom, increment_index(localBot)); 1.45 TASKQUEUE_STATS_ONLY(stats.record_push()); 1.46 return true; 1.47 @@ -665,7 +678,12 @@ 1.48 // This is necessary to prevent any read below from being reordered 1.49 // before the store just above. 1.50 OrderAccess::fence(); 1.51 - const_cast<E&>(t = _elems[localBot]); 1.52 + // g++ complains if the volatile result of the assignment is 1.53 + // unused, so we cast the volatile away. We cannot cast directly 1.54 + // to void, because gcc treats that as not using the result of the 1.55 + // assignment. However, casting to E& means that we trigger an 1.56 + // unused-value warning. So, we cast the E& to void. 1.57 + (void) const_cast<E&>(t = _elems[localBot]); 1.58 // This is a second read of "age"; the "size()" above is the first. 1.59 // If there's still at least one element in the queue, based on the 1.60 // "_bottom" and "age" we've read, then there can be no interference with