asb2m10 / dexed

DX7 FM multi plaform/multi format plugin
GNU General Public License v3.0
2.8k stars 241 forks source link

error: taking the absolute value of unsigned type 'char' has no effect, etc. #347

Closed yurivict closed 1 month ago

yurivict commented 2 years ago

Build fails on arm64 architecture:

/wrkdirs/usr/ports/audio/dexed/work/dexed-0.9.6-16-g1df9a58/Source/PluginData.cpp:113:13: error: taking the absolute value of unsigned type 'char' has no effect [-Werror,-Wabsolute-value]
    value = abs(value);
            ^
/wrkdirs/usr/ports/audio/dexed/work/dexed-0.9.6-16-g1df9a58/Source/PluginData.cpp:113:13: note: remove the call to 'abs' since unsigned values cannot be negative
    value = abs(value);
            ^~~
/wrkdirs/usr/ports/audio/dexed/work/dexed-0.9.6-16-g1df9a58/Source/PluginData.cpp:312:29: error: result of comparison of constant -1 with expression of type 'char' is always true [-Werror,-Wtautological-constant-out-of-range-compare]
    return clipboardContent != -1;
           ~~~~~~~~~~~~~~~~ ^  ~~
2 errors generated.

Version: 0.9.6-16-g1df9a58 clang-13 OS: FreeBSD 13

yurivict commented 2 years ago

These are failures on arm64 due to bugs in the C++ code.

asb2m10 commented 2 years ago

Yes but it is not the case of all compilers: https://stackoverflow.com/questions/2054939/is-char-signed-or-unsigned-by-default

I will check to fix this on all platforms

clausecker commented 2 years ago

@asb2m10 This is not a matter of compiler, but rather of the ABI of the platform you are programming for. ARM platforms have an unsigned character type, as have IBM platforms (PPC, S390) afaik. I've submitted a patch set to the FreeBSD bug tracker that addresses these issues. Please check if you can take over this patch.

asb2m10 commented 1 month ago

Patch has been applied