[vlc-devel] [PATCH] contrib: sidplay2: fix signed char stored as int8_t

Rémi Denis-Courmont remi at remlab.net
Sat Jan 11 03:47:08 CET 2020


Is overflowing conversion to signed type well defined in C++? I'm pretty sure it's implementation-defined in C.

Le 10 janvier 2020 18:54:08 GMT+09:00, Steve Lhomme <robux4 at ycbcr.xyz> a écrit :
>When using 0xXX notation the issue we also have to adjust the width.
>
>Fixes compilation with gcc 9 for Raspberry:
>
>compile:  arm-linux-gnueabihf-g++ -DHAVE_CONFIG_H
>-Icontrib/arm-linux-gnueabihf/include
>-Icontrib/arm-linux-gnueabihf/include -g -O2 -DHAVE_UNIX
>-I../../include -I../../include/sidplay -c xsid.cpp -fPIC -DPIC -o
>xsid.o
>xsid.cpp:101:1: error: narrowing conversion of ‘'\200'’ from ‘char’ to
>‘int8_t’ {aka ‘signed char’} [-Wnarrowing]
>  101 | };
>      | ^
>xsid.cpp:101:1: error: narrowing conversion of ‘'\224'’ from ‘char’ to
>‘int8_t’ {aka ‘signed char’} [-Wnarrowing]
>xsid.cpp:101:1: error: narrowing conversion of ‘'\251'’ from ‘char’ to
>‘int8_t’ {aka ‘signed char’} [-Wnarrowing]
>xsid.cpp:101:1: error: narrowing conversion of ‘'\274'’ from ‘char’ to
>‘int8_t’ {aka ‘signed char’} [-Wnarrowing]
>xsid.cpp:101:1: error: narrowing conversion of ‘'\316'’ from ‘char’ to
>‘int8_t’ {aka ‘signed char’} [-Wnarrowing]
>xsid.cpp:101:1: error: narrowing conversion of ‘'\341'’ from ‘char’ to
>‘int8_t’ {aka ‘signed char’} [-Wnarrowing]
>xsid.cpp:101:1: error: narrowing conversion of ‘'\362'’ from ‘char’ to
>‘int8_t’ {aka ‘signed char’} [-Wnarrowing]
>make[4]: *** [Makefile:409: xsid.lo] Error 1
>---
> contrib/src/sidplay2/rules.mak                |  1 +
> contrib/src/sidplay2/sidplay2-char-cast.patch | 13 +++++++++++++
> 2 files changed, 14 insertions(+)
> create mode 100644 contrib/src/sidplay2/sidplay2-char-cast.patch
>
>diff --git a/contrib/src/sidplay2/rules.mak
>b/contrib/src/sidplay2/rules.mak
>index 84c35ccfee7..de77935774a 100644
>--- a/contrib/src/sidplay2/rules.mak
>+++ b/contrib/src/sidplay2/rules.mak
>@@ -25,6 +25,7 @@ sidplay-libs: sidplay-libs-$(SID_VERSION).tar.gz
>.sum-sidplay2
> 	$(APPLY) $(SRC)/sidplay2/sidplay2-string.patch
> 	$(APPLY) $(SRC)/sidplay2/sidplay-fix-ln-s.patch
> 	$(APPLY) $(SRC)/sidplay2/sidplay2-resid-dependency.patch
>+	$(APPLY) $(SRC)/sidplay2/sidplay2-char-cast.patch
> 	$(MOVE)
> 
> .sidplay2: sidplay-libs
>diff --git a/contrib/src/sidplay2/sidplay2-char-cast.patch
>b/contrib/src/sidplay2/sidplay2-char-cast.patch
>new file mode 100644
>index 00000000000..14eda139606
>--- /dev/null
>+++ b/contrib/src/sidplay2/sidplay2-char-cast.patch
>@@ -0,0 +1,13 @@
>+--- sidplay-libs/libsidplay/src/xsid/xsid.cpp.char	2004-06-14
>22:08:02.000000000 +0200
>++++ sidplay-libs/libsidplay/src/xsid/xsid.cpp	2020-01-10
>08:41:49.454974200 +0100
>+@@ -96,8 +96,8 @@ const int8_t XSID::sampleConvertTable[16
>+ */
>+ const int8_t XSID::sampleConvertTable[16] =
>+ {
>+-    '\x80', '\x94', '\xa9', '\xbc', '\xce', '\xe1', '\xf2', '\x03',
>+-    '\x1b', '\x2a', '\x3b', '\x49', '\x58', '\x66', '\x73', '\x7f'
>++    (int8_t)0x80, (int8_t)0x94, (int8_t)0xa9, (int8_t)0xbc,
>(int8_t)0xce, (int8_t)0xe1, (int8_t)0xf2, (int8_t)0x03,
>++    (int8_t)0x1b, (int8_t)0x2a, (int8_t)0x3b, (int8_t)0x49,
>(int8_t)0x58, (int8_t)0x66, (int8_t)0x73, (int8_t)0x7f
>+ };
>+ 
>+ const char *XSID::credit =
>-- 
>2.17.1
>
>_______________________________________________
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
>https://mailman.videolan.org/listinfo/vlc-devel

-- 
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20200111/1e118277/attachment.html>


More information about the vlc-devel mailing list