Build fails on Archlinux with GCC 5.1.0
Popular easy-to-use and secure password manager
Brought to you by:
ronys
I apologize for double-posting this but the MLs[1] seem to have very low traffic.
GCC 5.1.0 entered the regular Archlinux repositories and either breaks the passwordsafe build or exposes an issue with the build:
rand.cpp: In function ‘bool pws_os::GetRandomData(void*, long unsigned int)’: rand.cpp:38:45: error: cannot convert ‘std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}’ to ‘bool’ in return return is.read(static_cast<char *>(p), len); ^
Full 'make' output: http://ix.io/iJh
Link to the AUR-package: https://aur.archlinux.org/packages/passwordsafe/
The package builds fine with the previous GCC 4.9.2 release.
Perhaps I can get a hint at whether I should report this to the GCC folks or if it's just a passwordsafe issue.
Regards,
Alexander Schnaidt
[1]
Original ML message:
https://sourceforge.net/p/passwordsafe/mailman/message/34138704/
Looks like a compiler issue to me:
std::basic_istream<char>::read() returns the std::basic_istream<char> object, which has a cast to bool operator defined (see, e.g., http://en.cppreference.com/w/cpp/io/basic_ios/operator_bool).
Looks like previous gompilers could deduce the cast correctly, gcc 5.1.0 apparently can't.
An acceptable workaround would be to change
return is.read(static_cast<char *="">(p), len);
to
return !is.read(static_cast<char *="">(p), len).fail();
Marking this as wont-fix. Let me know if you determine that it's not a compiler issue after all, and I'll re-open.
Thanks for the workaround, I'll bother the GCC upstream and report back.
Not a compiler issue, C++11 removed the implicit conversion from streams to void* and gcc-5 now implements that change. The conversion to bool that you refer to is explicit, so can't be used for implicit conversions, see (2) at http://en.cppreference.com/w/cpp/language/explicit for details of this language feature.
The code on line 38 needs to convert to bool explicitly:
Last edit: Jonathan Wakely 2015-06-01
Reported at:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66365
I see that https://sourceforge.net/p/passwordsafe/bugs/1253/ is pretty much the same case.
Actually, this was fixed in commit f158a3cf478b9adb18c07f3f2b322785ec3afb82:
Author: ronys ronys@users.sourceforge.net
Date: Sat Mar 14 20:53:11 2015 +0200
--- a/src/os/linux/rand.cpp
+++ b/src/os/linux/rand.cpp
@@ -35,7 +35,7 @@ bool pws_os::GetRandomData(void *p, unsigned long len)
ifstream is("/dev/urandom");
if (!is)
return false;
- return is.read(static_cast<char *="">(p), len);
+ return is.read(static_cast<char *="">(p), len).good();
}
static void get_failsafe_rnd(char * &p, unsigned &slen)