Page MenuHomePhabricator

[asan] Fix shifting compiler warnings when compiler in 64-bits
ClosedPublic

Authored by etienneb on Jun 20 2016, 11:42 AM.

Details

Summary

The MSVC compiler complains about implicit conversion of 32-bits constant to
64-bit when using this shiting pattern 1 << (<64-bit expr>).

Diff Detail

Event Timeline

etienneb updated this revision to Diff 61279.Jun 20 2016, 11:42 AM
etienneb retitled this revision from to [asan] Fix shifting compiler warnings when compiler in 64-bits.
etienneb updated this object.
etienneb added a reviewer: rnk.
etienneb added subscribers: chrisha, wang0109.
rnk edited edge metadata.Jun 20 2016, 12:28 PM

LLP64 strikes again. =P

I wonder if sanitizer_common.h should have this in it instead and use it everywhere instead of ((uptr)1): enum : uptr { UPtrOne = 1 };. Seems like a style question for Kostya.

In D21524#462485, @rnk wrote:

LLP64 strikes again. =P

I wonder if sanitizer_common.h should have this in it instead and use it everywhere instead of ((uptr)1): enum : uptr { UPtrOne = 1 };. Seems like a style question for Kostya.

Or, we could have a specific macro for address space shifting.

#define SHIFT(offset) (((uptr)1) << (offset))

With a better name :)

etienneb edited edge metadata.Jun 20 2016, 12:31 PM
etienneb added a subscriber: kcc.

kcc@ ? Could you tell me your coding-style preference to fix these shifting issues.
I'll fix them.

rnk accepted this revision.Jun 21 2016, 7:55 AM
rnk edited edge metadata.

lgtm

Let's fix the warnings now and Kostya can tell us how he'd rather write these checks when he gets back if he has an opinion.

This revision is now accepted and ready to land.Jun 21 2016, 7:55 AM
etienneb closed this revision.Jun 21 2016, 8:00 AM