Page MenuHome GnuPG

pinentry-qt4 needs -std=c++11 to compile with gcc-5.1
Closed, ResolvedPublic

Description

Building pinentry-qt4 with gcc-5.1 results in the error below. If I pass
-std=c++11 like indicated in the error message the build succeeds. Qt version is
4.8.6.

make[3]: Entering directory
'/var/tmp/paludis/build/app-crypt-pinentry-0.9.1/work/pinentry-0.9.1/qt4'
x86_64-pc-linux-gnu-g++ -DHAVE_CONFIG_H -I. -I.. -I.. -I../assuan -I../secmem
-I/usr/x86_64-pc-linux-gnu/include/ncursesw -I../pinen
try -march=native -pipe -O2 -Wall -DQT_SHARED
-I/usr/x86_64-pc-linux-gnu/include/qt4
-I/usr/x86_64-pc-linux-gnu/include/qt4/QtCore -
DQT_SHARED -I/usr/x86_64-pc-linux-gnu/include/qt4
-I/usr/x86_64-pc-linux-gnu/include/qt4/QtGui -I/usr/x86_64-pc-linux-gnu/include/qt4
-I/usr/x86_64-pc-linux-gnu/include/qt4/QtCore -march=native -pipe -O2 -pipe
-O2 -c -o pinentrydialog.o pinentrydialog.cpp
In file included from /usr/x86_64-pc-linux-gnu/include/c++/5.1.0/string:52:0,

from /usr/x86_64-pc-linux-gnu/include/qt4/QtCore/qstring.h:54,
from /usr/x86_64-pc-linux-gnu/include/qt4/QtCore/qobject.h:48,
from /usr/x86_64-pc-linux-gnu/include/qt4/QtGui/qwidget.h:47,
from /usr/x86_64-pc-linux-gnu/include/qt4/QtGui/qdialog.h:45,
from /usr/x86_64-pc-linux-gnu/include/qt4/QtGui/QDialog:1,
from pinentrydialog.h:27,
from pinentrydialog.cpp:24:

/usr/x86_64-pc-linux-gnu/include/c++/5.1.0/bits/basic_string.h: In instantiation
of 'union std::cxx11::basic_string<QChar, std::cha
r_traits<QChar>, secmem::alloc<QChar> >::<anonymous>':
/usr/x86_64-pc-linux-gnu/include/c++/5.1.0/bits/basic_string.h:119:7: required
from 'class std::
cxx11::basic_string<QChar, std::char_traits<QChar>,
secmem::alloc<QChar> >'
secstring.h:37:1: required from here
/usr/x86_64-pc-linux-gnu/include/c++/5.1.0/bits/basic_string.h:121:53: error:
member 'QChar std::__cxx11::basic_string<QChar, std::char_traits<QChar>,
secmem::alloc<QChar> >::<anonymous union>::_M_local_buf [8]' with constructor
not allowed in union

_CharT           _M_local_buf[_S_local_capacity + 1];
                                                   ^

/usr/x86_64-pc-linux-gnu/include/c++/5.1.0/bits/basic_string.h:121:53: note:
unrestricted unions only available with -std=c++11 or -std=gnu++11
Makefile:459: recipe for target 'pinentrydialog.o' failed
make[3]: Leaving directory
'/var/tmp/paludis/build/app-crypt-pinentry-0.9.1/work/pinentry-0.9.1/qt4'
make[3]: * [pinentrydialog.o] Error 1
Makefile:361: recipe for target 'all' failed
make[2]: Leaving directory
'/var/tmp/paludis/build/app-crypt-pinentry-0.9.1/work/pinentry-0.9.1/qt4'
make[2]:
* [all] Error 2
Makefile:437: recipe for target 'all-recursive' failed
make[1]: Leaving directory
'/var/tmp/paludis/build/app-crypt-pinentry-0.9.1/work/pinentry-0.9.1'
make[1]: * [all-recursive] Error 1
Makefile:378: recipe for target 'all' failed
make:
* [all] Error 2

Details

Version
0.9.1

Event Timeline

werner added a subscriber: werner.

Andre: Can we fix that without the need to require a newer gcc version?

From looking at the error (I don't have gcc 5 at hand) this looks to me like a
problem in the stdc++ library.

It appears that the basic_string implementation wants to put the templates class
(QChar) into a Union and it fails because it has a non-trivial constructor and
this is not allowed.

As this currently works, either the stdc++ library does this differently or gcc
does not check that rule.

Depending on the GCC Version during build configuration I guess we could add
-std=gnu++11 as the error message suggests if the GCC mayor version is > 5

aheinecke added a project: Restricted Project.Aug 6 2015, 6:20 PM

This will be fixed in the upcoming pinentry release as pinentry-qt no longer
uses std::string

the attached patch is a minimal patch to make older versions of pinentry-qt4
build cleanly with newer gcc.

I'm marking this as resolved as the currently released version of pinentry
compiles with gcc-5.1

aheinecke removed a project: Restricted Project.