Geonkick-Synthesizer / geonkick

Geonkick is a free software synthesizer capable of generating a wide range of percussive sounds, including kicks, snares, claps, hi-hats, shakers, and also unique effect sounds.
https://geonkick.org
GNU General Public License v3.0
109 stars 9 forks source link

Base64EncoderDecoder.cpp: error: narrowing conversion of ‘-1’ from ‘int’ to ‘char’ [-Wnarrowing] #7

Closed Xunop closed 12 months ago

Xunop commented 12 months ago

Hello, When building on the riscv64 platform, I encountered the following error:

/build/geonkick/src/geonkick-v3.0.1/src/Base64EncoderDecoder.cpp:66:33: error: narrowing conversion of ‘-1’ from ‘int’ to ‘char’ [-Wnarrowing]
...

The code works fine on the x86_64 device. To address this error, I made the following modifications to src/Base64EncoderDecoder.cpp based on the information provided in the error message:

diff --git a/src/Base64EncoderDecoder.cpp b/src/Base64EncoderDecoder.cpp
index 549600e..ec0e3ec 100644
--- a/src/Base64EncoderDecoder.cpp
+++ b/src/Base64EncoderDecoder.cpp
@@ -63,22 +63,22 @@ std::vector<float> Base64EncoderDecoder::decode(const std::string &input)
    auto decodeChar = [&](char c) {
        constexpr std::array<char, 256> base64CharMap = {{
                /* Initialize with -1 for characters not in base64Chars */
-               -1, -1, -1, -1, -1, -1, -1, -1,
-               -1, -1, -1, -1, -1, -1, -1, -1,
-               -1, -1, -1, -1, -1, -1, -1, -1,
-               -1, -1, -1, -1, -1, -1, -1, -1,
-               -1, -1, -1, -1, -1, -1, -1, -1,
-               -1, -1, -1, 62, -1, -1, -1, 63,
+               (char)-1, (char)-1, (char)-1, (char)-1, (char)-1, (char)-1, (char)-1, (char)-1,
+               (char)-1, (char)-1, (char)-1, (char)-1, (char)-1, (char)-1, (char)-1, (char)-1,
+               (char)-1, (char)-1, (char)-1, (char)-1, (char)-1, (char)-1, (char)-1, (char)-1,
+               (char)-1, (char)-1, (char)-1, (char)-1, (char)-1, (char)-1, (char)-1, (char)-1,
+               (char)-1, (char)-1, (char)-1, (char)-1, (char)-1, (char)-1, (char)-1, (char)-1,
+               (char)-1, (char)-1, (char)-1, 62, (char)-1, (char)-1, (char)-1, 63,
                52, 53, 54, 55, 56, 57, 58, 59,
-               60, 61, -1, -1, -1, -1, -1, -1,
-               -1, 0, 1, 2, 3, 4, 5, 6,
+               60, 61, (char)-1, (char)-1, (char)-1, (char)-1, (char)-1, (char)-1,
+               (char)-1, 0, 1, 2, 3, 4, 5, 6,
                7, 8, 9, 10, 11, 12, 13, 14,
                15, 16, 17, 18, 19, 20, 21, 22,
-               23, 24, 25, -1, -1, -1, -1, -1,
-               -1, 26, 27, 28, 29, 30, 31, 32,
+               23, 24, 25, (char)-1, (char)-1, (char)-1, (char)-1, (char)-1,
+               (char)-1, 26, 27, 28, 29, 30, 31, 32,
                33, 34, 35, 36, 37, 38, 39, 40,
                41, 42, 43, 44, 45, 46, 47, 48,
-               49, 50, 51, -1, -1, -1, -1, -1
+               49, 50, 51, (char)-1, (char)-1, (char)-1, (char)-1, (char)-1
            }};
        return static_cast<unsigned char>(base64CharMap[static_cast<unsigned char>(c)]);
         };

After these changes, the code should now work on the riscv64 device. If these changes are feasible, I am prepare to create a pull request to fix it.

iurienistor commented 12 months ago

Hi! Thanks for pointing out to this issue. Now this commit should fix it - https://github.com/Geonkick-Synthesizer/geonkick/commit/284055dffe8cde61076edb24c038412c68217af5