Closed Bug 1226277 Opened 10 years ago Closed 10 years ago

"warning C4146: unary minus operator applied to unsigned type, result still unsigned" in AtomicOperations-x86-shared.h

Categories

(Core :: JavaScript Engine: JIT, defect)

Unspecified
Windows
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla45
Tracking Status
firefox45 --- fixed

People

(Reporter: RyanVM, Assigned: lth)

References

Details

Attachments

(1 file)

Looks like this code was added by bug 1142593. js\src\jit/x86-shared/AtomicOperations-x86-shared.h(522) : warning C4146: unary minus operator applied to unsigned type, result still unsigned The line in question: http://hg.mozilla.org/mozilla-central/file/a523d4c7efe2/js/src/jit/x86-shared/AtomicOperations-x86-shared.h#l522 520 MSC_FETCHADDOP(uint16_t, short, _InterlockedExchangeAdd16) 521 MSC_FETCHADDOP(int32_t, long, _InterlockedExchangeAdd) >> 522 MSC_FETCHADDOP(uint32_t, long, _InterlockedExchangeAdd) 523 524 # undef MSC_FETCHADDOP
Assignee: nobody → lhansen
/me thinks that, perhaps, in the macro MSC_FETCHADDOP, it should be -(U)val and not (U)-val.
Attachment #8689910 - Flags: review?(benj)
Comment on attachment 8689910 [details] [diff] [review] fix MSVC warning with a cast Review of attachment 8689910 [details] [diff] [review]: ----------------------------------------------------------------- OK, I think we could use C++ coercions here and above. ::: js/src/jit/x86-shared/AtomicOperations-x86-shared.h @@ +510,5 @@ > } \ > template<> inline T \ > js::jit::AtomicOperations::fetchSubSeqCst(T* addr, T val) { \ > static_assert(sizeof(T) <= 4, "not available for 8-byte values yet"); \ > + return (T)xadd((U volatile*)addr, -(U)val); \ Any way you can use C++ coercions here for the coercion into T and the second U coercion? return T(xadd((U volatile*) addr, -U(val))); \
Attachment #8689910 - Flags: review?(benj) → review+
(In reply to Benjamin Bouvier [:bbouvier] from comment #3) > Comment on attachment 8689910 [details] [diff] [review] > fix MSVC warning with a cast > > Review of attachment 8689910 [details] [diff] [review]: > ----------------------------------------------------------------- > > Any way you can use C++ coercions here for the coercion into T and the > second U coercion? It's a good point, but I will still land this as-is to minimize time spent on it today.
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: