bde icon indicating copy to clipboard operation
bde copied to clipboard

Build will fail in Linux ARM architectures, Narrowing error at bdlde_base64decoder.cpp

Open hydexon opened this issue 6 years ago • 3 comments

Building BDE in a Raspberry Pi 3 Model B, using DietPi with GCC 6.5.0, ARM7hf, will fail since C/C++ datatype char is an implementation defined datatype, and in ARM architecture, they are unsigned chars by default.

The error stats here, at line 78 of bdlde_base64decoder.cpp

static const char decoding[256] = {
    //  0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
    // --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --
       -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  // 00
       -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  // 10
       -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,  // 20
       52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,  // 30
       -1,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14,  // 40
       15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,  // 50
       -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,  // 60
       41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,  // 70
       -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  // 80
       -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  // 90
       -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  // A0
       -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  // B0
       -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  // C0
       -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  // D0
       -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  // E0
       -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  // F0
};

changing to signed char instead of char may help, but also requires also changing the static class variable s_decoding_p from const char *const bdlde::Base64Decoder::s_decoding_p = decoding; to const signed char *const bdlde::Base64Decoder::s_decoding_p = decoding;

Another solution can be is swap from char to int

hydexon avatar Feb 25 '18 23:02 hydexon

ARM platform is not officially supported by the BDE.

osubboo avatar Feb 26 '18 12:02 osubboo

@osubboo - this issue has nothing to do with ARM, it's just a happy accident that your toolchain is defaulting to signed chars on your platform.

It's considered good practice (e.g. MISRA demands that) not to use the char datatype to store numerical values like this; you should always use signed char or unsigned char, depending on your intent.

ghost avatar Aug 01 '18 11:08 ghost

Why not use something more specific like: int8_t ?

tolysz avatar Aug 08 '18 10:08 tolysz