Bug 364495 - Compilation for ARM fails with Qt 5.7.0 because of narrowing conversion:
Summary: Compilation for ARM fails with Qt 5.7.0 because of narrowing conversion:
Status: RESOLVED FIXED
Alias: None
Product: qca
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 2.1.1
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Ivan Romanov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-06-19 10:43 UTC by Rolf Eike Beer
Modified: 2016-06-27 16:24 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rolf Eike Beer 2016-06-19 10:43:35 UTC
Using gcc 5.4.0, worked fine with 5.6.1.

[ 35%] Building CXX object src/CMakeFiles/qca-qt5.dir/botantools/botan/exceptn.cpp.o
cd /tmp/e2/build/build/src && /opt/emlix/test/bin/arm-unknown-linux-gnueabi-g++  --sysroot=/opt/emlix/test/sysroot  -DBOTAN_EXT_ALLOC_MMAP -DBOTAN_EXT_MUTEX_QT -DBOTAN_KARAT_MUL_THRESHOLD=12 -DBOTAN_KARAT_SQR_THRESHOLD=12 -DBOTAN_MINIMAL_BIGINT -DBOTAN_MP_WORD_BITS=32 -DBOTAN_NO_CONF_H -DBOTAN_NO_INIT_H -DBOTAN_TOOLS_ONLY -DBOTAN_TYPES_QT -DQCA_MAKEDLL -DQCA_PLUGIN_PATH=\"/opt/emlix/test/sysroot/usr/lib/qt5/plugins\" -DQCA_SYSTEMSTORE_PATH=\"/tmp/e2/build/qca/certs/rootcerts.pem\" -DQT_CORE_LIB -DQT_DISABLE_DEPRECATED_BEFORE=0 -DQT_NO_DEBUG -D_BSD_SOURCE -I/tmp/e2/build/build/src -I/tmp/e2/build/qca/src -I/tmp/e2/build/qca/include/QtCrypto -I/tmp/e2/build/build -I/tmp/e2/build/qca/src/support -I/tmp/e2/build/qca/src/botantools/botan -isystem /opt/emlix/test/sysroot/usr/include/qt5 -isystem /opt/emlix/test/sysroot/usr/include/qt5/QtCore -isystem /opt/emlix/test/mkspecs/emlix/linux-arm-g++ -I/opt/emlix/test/sysroot/usr/include/qt5/QtNetwork  -Wcast-align -Wnon-virtual-dtor -Wno-long-long -ansi -Wundef -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -fno-check-new -fno-common -fPIC   -fPIC -std=gnu++11 -o CMakeFiles/qca-qt5.dir/botantools/botan/exceptn.cpp.o -c /tmp/e2/build/qca/src/botantools/botan/exceptn.cpp
In file included from /opt/emlix/test/sysroot/usr/include/c++/5.4.0/arm-unknown-linux-gnueabi/bits/os_defines.h:39:0,
                 from /opt/emlix/test/sysroot/usr/include/c++/5.4.0/arm-unknown-linux-gnueabi/bits/c++config.h:482,
                 from /opt/emlix/test/sysroot/usr/include/c++/5.4.0/cstddef:44,
                 from /opt/emlix/test/sysroot/usr/include/qt5/QtCore/qglobal.h:45,
                 from /opt/emlix/test/sysroot/usr/include/qt5/QtCore/QtGlobal:1,
                 from /tmp/e2/build/qca/src/botantools/botan/botan/types.h:38,
                 from /tmp/e2/build/qca/src/botantools/botan/botan/exceptn.h:37,
                 from /tmp/e2/build/qca/src/botantools/botan/exceptn.cpp:34:
/opt/emlix/test/sysroot/usr/include/features.h:148:3: warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
 # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
   ^
/tmp/e2/build/qca/src/qca_textfilter.cpp: In function 'QByteArray QCA::b64decode(const QByteArray&, bool*)':
/tmp/e2/build/qca/src/qca_textfilter.cpp:314:2: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
  };
  ^


Reproducible: Always
Comment 1 Rolf Eike Beer 2016-06-27 16:24:40 UTC
Git commit 601fd3a05141c614ae48a3ddac44194d669eaae1 by Rolf Eike Beer.
Committed on 27/06/2016 at 16:24.
Pushed by dakon into branch 'master'.

fix base64 decoding on ARM

This code was broken on ARM and other architectures where "char" is unsigned by
default.

First, it breaks with newer compilers with errors like:

  .../src/qca_textfilter.cpp:314:2: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]

Second, if the compiler would just allow this conversion then the unsigned char
would hold 255, which would not be sign extended when cast to an int later, so
all the checks "< 0" will never trigger, and so invalid input characters cannot
be detected.

REVIEW:128295

M  +1    -1    src/qca_textfilter.cpp

http://commits.kde.org/qca/601fd3a05141c614ae48a3ddac44194d669eaae1