Skip to content

Bad conversion from int to unsigned char #485

@tanis2000

Description

@tanis2000

I'm using hxcpp version 3.3.49 and Lime 3.0.0

I transpile the SimpleImage example of Lime to iOS (but any native C++ target is the same).

When compiling I get the following error:

./src/lime/graphics/format/BMP.cpp:307:23: warning: implicit conversion from 'int' to 'unsigned char' changes value from 11824 to 48 [-Wconstant-conversion]


            data->b[position] = (int)11824;

Since some of those values are also negative or bigger than a char, they become 0 during the assignment, thus leading to bugs.
Example:

./src/lime/graphics/format/BMP.cpp:402:35: warning: implicit conversion from 'int' to 'unsigned char' changes value from -65536 to 0 [-Wconstant-conversion]


                    data->b[(position + (int)1)] = (int)-65536;

Here's the generated BMP.cpp file: https://gist.github.com/tanis2000/d2e9e1d700c13aef0d6c035e2b9811f9#file-bmp-cpp-L307
And here's the original BMP.hx file: https://gist.github.com/tanis2000/3181b0c23184da839d4eda80ba125ca6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions