Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/debug/ee/arm64/arm64walker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ BOOL NativeWalker::DecodePCRelativeBranchInst(PT_CONTEXT context, const PRD_TYP
bit_pos = bit_pos + 32;
}

PCODE bit_val = 1 << bit_pos;
PCODE bit_val = PCODE{ 1 } << bit_pos;
if (opcode & 0x01000000) //TBNZ
{
result = (RegContent & bit_val) != 0;
Expand Down
6 changes: 3 additions & 3 deletions src/gcinfo/gcinfoencoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2661,7 +2661,7 @@ int BitStreamWriter::SizeofVarLengthUnsigned( size_t n, UINT32 base)
// If a value gets so big we are probably doing something wrong
_ASSERTE(((INT32)(UINT32)n) >= 0);
_ASSERTE((base > 0) && (base < BITS_PER_SIZE_T));
size_t numEncodings = 1 << base;
size_t numEncodings = size_t{ 1 } << base;
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous line checks that base is lower then BITS_PER_SIZE_T, on TARGET_64 it would be 64.
So then if 32 < base < 64 it would produce the wrong result in the old variant.

int bitsUsed;
for(bitsUsed = base+1; ; bitsUsed += base+1)
{
Expand All @@ -2682,7 +2682,7 @@ int BitStreamWriter::EncodeVarLengthUnsigned( size_t n, UINT32 base)
// If a value gets so big we are probably doing something wrong
_ASSERTE(((INT32)(UINT32)n) >= 0);
_ASSERTE((base > 0) && (base < BITS_PER_SIZE_T));
size_t numEncodings = 1 << base;
size_t numEncodings = size_t{ 1 } << base;
int bitsUsed;
for(bitsUsed = base+1; ; bitsUsed += base+1)
{
Expand All @@ -2704,7 +2704,7 @@ int BitStreamWriter::EncodeVarLengthUnsigned( size_t n, UINT32 base)
int BitStreamWriter::EncodeVarLengthSigned( SSIZE_T n, UINT32 base )
{
_ASSERTE((base > 0) && (base < BITS_PER_SIZE_T));
size_t numEncodings = 1 << base;
size_t numEncodings = size_t{ 1 } << base;
for(int bitsUsed = base+1; ; bitsUsed += base+1)
{
size_t currentChunk = ((size_t) n) & (numEncodings-1);
Expand Down
4 changes: 2 additions & 2 deletions src/inc/gcinfodecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ class BitStreamReader
inline size_t DecodeVarLengthUnsigned( int base )
{
_ASSERTE((base > 0) && (base < (int)BITS_PER_SIZE_T));
size_t numEncodings = 1 << base;
size_t numEncodings = size_t{ 1 } << base;
size_t result = 0;
for(int shift=0; ; shift+=base)
{
Expand All @@ -381,7 +381,7 @@ class BitStreamReader
inline SSIZE_T DecodeVarLengthSigned( int base )
{
_ASSERTE((base > 0) && (base < (int)BITS_PER_SIZE_T));
size_t numEncodings = 1 << base;
size_t numEncodings = size_t{ 1 } << base;
SSIZE_T result = 0;
for(int shift=0; ; shift+=base)
{
Expand Down
49 changes: 13 additions & 36 deletions src/inc/warningcontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,43 +15,20 @@
#if defined(_MSC_VER)
#pragma warning(error :4007) // 'main' : must be __cdecl
#pragma warning(error :4013) // 'function' undefined - assuming extern returning int
#pragma warning(error :4071) // no function prototype given
#pragma warning(error :4072) // no function prototype given (fastcall)
#pragma warning(3 :4092) // sizeof returns 'unsigned long'
//#pragma warning(error :4102) // "'%$S' : unreferenced label"
#pragma warning(3 :4121) // structure is sensitive to alignment
#pragma warning(3 :4125) // decimal digit in octal sequence
#pragma warning(3 :4130) // logical operation on address of string constant
#pragma warning(3 :4132) // const object should be initialized
#pragma warning(error :4171) // no function prototype given (old style)
#pragma warning(4 :4177) // pragma data_seg s/b at global scope
#pragma warning(4 :4206) // Source File is empty
#pragma warning(3 :4212) // function declaration used ellipsis
#pragma warning(error :4259) // pure virtual function was not defined
#pragma warning(disable :4291) // delete not defined for new, c++ exception may cause leak
#pragma warning(disable :4302) // truncation from '%$S' to '%$S'
#pragma warning(disable :4311) // pointer truncation from '%$S' to '%$S'
#pragma warning(disable :4312) // '<function-style-cast>' : conversion from '%$S' to '%$S' of greater size
#pragma warning(disable :4334) // result of 32-bit shift implicitly converted to 64 bits
#pragma warning(disable :4430) // missing type specifier: C++ doesn't support default-int
#pragma warning(3 :4092) // sizeof returns 'unsigned long'
#pragma warning(error :4102) // "'%$S' : unreferenced label"
#pragma warning(3 :4121) // structure is sensitive to alignment
#pragma warning(3 :4125) // decimal digit in octal sequence
#pragma warning(3 :4130) // logical operation on address of string constant
#pragma warning(3 :4132) // const object should be initialized
#pragma warning(4 :4177) // pragma data_seg s/b at global scope
#pragma warning(3 :4212) // function declaration used ellipsis
#pragma warning(disable :4291) // delete not defined for new, c++ exception may cause leak
#pragma warning(disable :4302) // truncation from '%$S' to '%$S'
#pragma warning(disable :4311) // pointer truncation from '%$S' to '%$S'
#pragma warning(disable :4312) // '<function-style-cast>' : conversion from '%$S' to '%$S' of greater size
#pragma warning(disable :4477) // format string '%$S' requires an argument of type '%$S', but variadic argument %d has type '%$S'
#pragma warning(3 :4509) // "nonstandard extension used: '%$S' uses SEH and '%$S' has destructor"
//
// But beware of doing a return from inside such a try block:
//
// int foo()
// {
// ClassWithDestructor c;
// __try {
// return 0;
// } __finally {
// printf("in finally");
// }
//
// as (it's a bug) the return value gets toasted. So DON'T casually
// dismiss this warning if you're compiling w/o CXX EH turned on (the default).

#pragma warning(3 :4530) // C++ exception handler used, but unwind semantics are not enabled. Specify -GX
#pragma warning(3 :4530) // C++ exception handler used, but unwind semantics are not enabled. Specify -GX
#pragma warning(error :4551) // Function call missing argument list

#pragma warning(error :4700) // Local used w/o being initialized
Expand Down
6 changes: 3 additions & 3 deletions src/jit/emitarm64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3545,7 +3545,7 @@ void emitter::emitIns_R_I(instruction ins, emitAttr attr, regNumber reg, ssize_t
{
if (loByte == 0xFF)
{
imm8 |= (1 << pos);
imm8 |= (ssize_t{1} << pos);
}
uimm >>= 8;
pos++;
Expand Down Expand Up @@ -10658,7 +10658,7 @@ void emitter::emitDispExtendReg(regNumber reg, insOpts opt, ssize_t imm)
if (imm > 0)
{
printf("*");
emitDispImm(1 << imm, false);
emitDispImm(ssize_t{1} << imm, false);
}
}
}
Expand Down Expand Up @@ -11350,7 +11350,7 @@ void emitter::emitDispIns(
const ssize_t mask8 = 0xFF;
for (unsigned b = 0; b < 8; b++)
{
if (imm & (1 << b))
if (imm & (ssize_t{1} << b))
{
imm64 |= (mask8 << (b * 8));
}
Expand Down
2 changes: 1 addition & 1 deletion src/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17012,7 +17012,7 @@ void GenTree::ParseArrayAddressWork(
// If one op is a constant, continue parsing down.
if (gtOp.gtOp2->IsCnsIntOrI())
{
ssize_t subMul = 1 << gtOp.gtOp2->gtIntConCommon.IconValue();
ssize_t subMul = ssize_t{1} << gtOp.gtOp2->gtIntConCommon.IconValue();
gtOp.gtOp1->ParseArrayAddressWork(comp, inputMul * subMul, pArr, pInxVN, pOffset, pFldSeq);
return;
}
Expand Down
28 changes: 14 additions & 14 deletions src/md/inc/verifylayouts.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,21 @@
// class VerifyLayoutsMD
// {
//
// static const expected_offset_of_first_field_in_CMiniMdRW = 208;
// static const actual_offset_of_first_field_in_CMiniMdRW =
// static const int expected_offset_of_first_field_in_CMiniMdRW = 208;
// static const int actual_offset_of_first_field_in_CMiniMdRW =
// 208;
// static const offset_of_field_after_CMiniMdRW_m_Schema =
// static const int offset_of_field_after_CMiniMdRW_m_Schema =
// 312;
// static const offset_of_field_after_CMiniMdRW_m_Tables =
// static const int offset_of_field_after_CMiniMdRW_m_Tables =
// 316;
// ... many more lines like this covering all fields in all marked up types ...
//
//
// static const alignment_of_first_field_in_CMiniMdRW =
// static const int alignment_of_first_field_in_CMiniMdRW =
// 4;
// static const alignment_of_field_after_CMiniMdRW_m_Schema =
// static const int alignment_of_field_after_CMiniMdRW_m_Schema =
// 8;
// static const alignment_of_field_after_CMiniMdRW_m_Tables =
// static const int alignment_of_field_after_CMiniMdRW_m_Tables =
// 8;
// ... many more lines like this cover all fields in all marked up types ...
//
Expand Down Expand Up @@ -123,16 +123,16 @@ class VerifyLayoutsMD
#define END_TYPE(typeName, typeAlign) END_TYPE_ESCAPED(typeName, typeName, typeAlign)

#define BEGIN_TYPE_ESCAPED(typeName, typeNameEscaped, initialFieldOffset) \
static const expected_offset_of_first_field_in_##typeNameEscaped## = initialFieldOffset; \
static const actual_offset_of_first_field_in_##typeNameEscaped## =
static const int expected_offset_of_first_field_in_##typeNameEscaped## = initialFieldOffset; \
static const int actual_offset_of_first_field_in_##typeNameEscaped## =

#define ALIGN_FIELD_ESCAPED(typeName, typeNameEscaped, fieldName, fieldSize, fieldAlign) \
offsetof(IGNORE_COMMAS(typeName), fieldName); \
static const offset_of_field_after_##typeNameEscaped##_##fieldName =
static const int offset_of_field_after_##typeNameEscaped##_##fieldName =

#define BITFIELD(typeName, fieldName, fieldOffset, fieldSize) \
fieldOffset; \
static const offset_of_field_after_##typeName##_##fieldName =
static const int offset_of_field_after_##typeName##_##fieldName =

#define END_TYPE_ESCAPED(typeName, typeNameEscaped, typeAlignentSize) \
sizeof(typeName);
Expand All @@ -145,13 +145,13 @@ class VerifyLayoutsMD
#undef BITFIELD

#define BEGIN_TYPE_ESCAPED(typeName, escapedTypeName, initialFieldOffset) \
static const alignment_of_first_field_in_##escapedTypeName =
static const int alignment_of_first_field_in_##escapedTypeName =
#define ALIGN_FIELD_ESCAPED(typeName, escapedTypeName, fieldName, fieldSize, fieldAlign) \
fieldAlign; \
static const alignment_of_field_after_##escapedTypeName##_##fieldName =
static const int alignment_of_field_after_##escapedTypeName##_##fieldName =
#define BITFIELD(typeName, fieldName, fieldOffset, fieldSize) \
fieldSize; \
static const alignment_of_field_after_##typeName##_##fieldName =
static const int alignment_of_field_after_##typeName##_##fieldName =
#define END_TYPE_ESCAPED(typeName, escapedTypeName, typeAlignmentSize) \
typeAlignmentSize;

Expand Down
4 changes: 2 additions & 2 deletions src/vm/methodtablebuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7924,7 +7924,7 @@ VOID MethodTableBuilder::PlaceInstanceFields(MethodTable ** pByValueClassCach
for (i = 0; i < MAX_LOG2_PRIMITIVE_FIELD_SIZE; i++) {
DWORD j;

if (IS_ALIGNED(dwCumulativeInstanceFieldPos, 1<<(i+1)))
if (IS_ALIGNED(dwCumulativeInstanceFieldPos, size_t{ 1 } << (i + 1)))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cast is not necessary here, the I goes from 0 to MAX_LOG2_PRIMITIVE_FIELD_SIZE which is 3

continue;

// check whether there are any bigger fields
Expand Down Expand Up @@ -7976,7 +7976,7 @@ VOID MethodTableBuilder::PlaceInstanceFields(MethodTable ** pByValueClassCach
}

// Place the field
dwCumulativeInstanceFieldPos = (DWORD)ALIGN_UP(dwCumulativeInstanceFieldPos, 1 << i);
dwCumulativeInstanceFieldPos = (DWORD)ALIGN_UP(dwCumulativeInstanceFieldPos, size_t{ 1 } << i);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cast is not necessary here, the I goes from 0 to MAX_LOG2_PRIMITIVE_FIELD_SIZE which is 3

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VS team agreed that static_cast<size_t>(1 << I) should not produce the warning, but I think the fix will get some time, so it is better to go with the current solution.


pFieldDescList[j].SetOffset(dwCumulativeInstanceFieldPos - dwOffsetBias);
dwCumulativeInstanceFieldPos += (1 << i);
Expand Down
2 changes: 1 addition & 1 deletion src/zap/nativeformatwriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ namespace NativeFormat

bool fFirstIsLeaf = false, fSecondIsLeaf = false;
Vertex * pFirst = ExpandBlock(index, depth - 1, false, &fFirstIsLeaf);
Vertex * pSecond = ExpandBlock(index + (1 << (depth - 1)), depth - 1, true, &fSecondIsLeaf);
Vertex * pSecond = ExpandBlock(index + (size_t{ 1 } << (depth - 1)), depth - 1, true, &fSecondIsLeaf);

Vertex * pPop;

Expand Down