Menu

#1251 Build fails on Archlinux with GCC 5.1.0

v1.0_(example)
closed
None
1
2015-06-01
2015-05-27
No

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/

Related

Bugs: #1253

Discussion

  • Rony Shapiro

    Rony Shapiro - 2015-05-27
    • status: open --> wont-fix
    • assigned_to: Rony Shapiro
     
  • Rony Shapiro

    Rony Shapiro - 2015-05-27

    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.

     
  • Alexander Schnaidt

    Thanks for the workaround, I'll bother the GCC upstream and report back.

     
  • Jonathan Wakely

    Jonathan Wakely - 2015-06-01

    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:

    return static_cast<bool>(is.read(static_cast<char *>(p), len));
    
     

    Last edit: Jonathan Wakely 2015-06-01
  • Rony Shapiro

    Rony Shapiro - 2015-06-01
    • status: wont-fix --> closed
     
  • Rony Shapiro

    Rony Shapiro - 2015-06-01

    Actually, this was fixed in commit f158a3cf478b9adb18c07f3f2b322785ec3afb82:
    Author: ronys ronys@users.sourceforge.net
    Date: Sat Mar 14 20:53:11 2015 +0200

    Fix for Fedora 22, applicable to all Linux builds
    
    From Jan Henning
    

    --- 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)

     

Log in to post a comment.