Skip to content

C4244 compiler warnings: type conversions causing possible loss of data #3

@xthdraft

Description

@xthdraft

As pointed out in a closed issue, compiling for electron using:
node-gyp rebuild --target=3.0.6 --arch=x64 --dist-url=https://atom.io/download/electron
causes many C4244 warnings.

These seem benign, as the compiler does implicit type conversions.
I nevertheless suppressed these warnings by using casts in the code for node-stringbuilder.c
eg: buffer[resultListLength++] = (uint32_t)starePointer + 1; // approx line 73
buffer[resultListLength++] = (uint32_t)starePointer + 1; // approx line 133
buffer[resultListLength++] = (uint32_t)sourcePointer + 1; // approx line 250
int64_t log2Floor(int64_t n) {return (int64_t) (floor(log2((double)n))); // approx line 488
int64_t addedLength = (int64_t) pow((double)2, (double)(i - 1)) * contentBufferLength; // 848
int64_t realAddedCount = (int64_t)pow((double)2, (double)log2Count); // approx 851
int64_t addedLength = (int64_t)pow((double)2,(double)( i - 1)) * originalLength; // approx 1188
int64_t realAddedCount = (int64_t)pow((double)2, (double)log2Count); // approx 1191

But these explicit casts are probably not necessary, and whether they'd impact on performance anyway I'm not sure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions