PR 438: Use ::byte instead of byte

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

PR 438: Use ::byte instead of byte

Jeffrey Walton-3
Hi Everyone,

We have a PR for "Use ::byte instead of byte", https://github.com/weidai11/cryptopp/pull/438/files.

The background is C++17 is adding std::byte, and its causing some compile issues for folks with GCC 7 and above. The issue is due to (https://github.com/weidai11/cryptopp/blob/master/config.h#L197):

    // put in global namespace to avoid ambiguity with other byte typedefs
    typedef unsigned char byte;

I think we have a few options, but its not clear to me which is the best at the moment. One of them includes:

    #if CRYPTOPP_CXX17
        typedef std::byte byte;
    #else
        // put in global namespace to avoid ambiguity with other byte typedefs
        typedef unsigned char byte;
    #endif

Or maybe even:

    #if CRYPTOPP_CXX17
        using byte = std::byte;
    #else
       ...

If you have any comments, please add them to the PR.

Jeff

--
--
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to [hidden email].
More information about Crypto++ and this group is available at http://www.cryptopp.com.
---
You received this message because you are subscribed to the Google Groups "Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PR 438: Use ::byte instead of byte

Jeffrey Walton-3


On Sunday, June 18, 2017 at 3:35:10 PM UTC-4, Jeffrey Walton wrote:
Hi Everyone,

We have a PR for "Use ::byte instead of byte", <a href="https://github.com/weidai11/cryptopp/pull/438/files" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fweidai11%2Fcryptopp%2Fpull%2F438%2Ffiles\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE1yNlYsxFyQ4C1SC58v8__YufZjA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fweidai11%2Fcryptopp%2Fpull%2F438%2Ffiles\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE1yNlYsxFyQ4C1SC58v8__YufZjA&#39;;return true;">https://github.com/weidai11/cryptopp/pull/438/files.

The background is C++17 is adding std::byte, and its causing some compile issues for folks with GCC 7 and above. The issue is due to (<a href="https://github.com/weidai11/cryptopp/blob/master/config.h#L197" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fweidai11%2Fcryptopp%2Fblob%2Fmaster%2Fconfig.h%23L197\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHhMmJTcSd6ldGFtfh2n5rOCEnnPw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fweidai11%2Fcryptopp%2Fblob%2Fmaster%2Fconfig.h%23L197\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHhMmJTcSd6ldGFtfh2n5rOCEnnPw&#39;;return true;">https://github.com/weidai11/cryptopp/blob/master/config.h#L197):

    // put in global namespace to avoid ambiguity with other byte typedefs
    typedef unsigned char byte;

I think we have a few options, but its not clear to me which is the best at the moment. One of them includes:

    #if CRYPTOPP_CXX17
        typedef std::byte byte;
    #else
        // put in global namespace to avoid ambiguity with other byte typedefs
        typedef unsigned char byte;
    #endif

Or maybe even:

    #if CRYPTOPP_CXX17
        using byte = std::byte;
    #else
       ...

If you have any comments, please add them to the PR.

Here's the kind of pain point I would prefer to avoid. I would prefer things "just work" when written naturally like programmers do (from http://www.modernescpp.com/index.php/c-17-more-details-about-the-library):

    You can use the function std::to_integer(std::byte b) to
    convert a std::byte to an integer type and the call
    std::byte{integer} to do it the other way around. integer
    has to be a non-negative value smaller than
    std::numeric_limits<unsigned_char>::max().

Jeff

--
--
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to [hidden email].
More information about Crypto++ and this group is available at http://www.cryptopp.com.
---
You received this message because you are subscribed to the Google Groups "Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PR 438: Use ::byte instead of byte

Jeffrey Walton-3
In reply to this post by Jeffrey Walton-3


On Sunday, June 18, 2017 at 3:35:10 PM UTC-4, Jeffrey Walton wrote:
Hi Everyone,

We have a PR for "Use ::byte instead of byte", <a href="https://github.com/weidai11/cryptopp/pull/438/files" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fweidai11%2Fcryptopp%2Fpull%2F438%2Ffiles\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE1yNlYsxFyQ4C1SC58v8__YufZjA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fweidai11%2Fcryptopp%2Fpull%2F438%2Ffiles\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE1yNlYsxFyQ4C1SC58v8__YufZjA&#39;;return true;">https://github.com/weidai11/cryptopp/pull/438/files.

We are getting ready to make the change to accommodate C++17 and std::byte. Its not a problem with the library per se; rather its an issue with *user* code that still performs 'using namespace std;'. Also see Herb Sutter's "Migrating to Namespaces" (http://www.drdobbs.com/cpp/migrating-to-namespaces/184404271).

We don't know what the change is at the moment. There's a few paths we can take, and we will be looking for consensus over the next several days. A viable option is "do nothing" and fix the user code.

There's a wiki page available that's documenting the change. Once the change is in, it will tell users how to migrate. Also see https://www.cryptopp.com/wiki/Std::byte on the wiki.

If you have some time, please review the wiki page, run some code under -std=c++17, and provide some feedback. A C++17 compiler can be found in Fedora 26, which has GCC 7.1. Debian 8.8 has GCC 7 but you have to enable Experimental. I don't know about MS compilers.

Jeff

--
--
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to [hidden email].
More information about Crypto++ and this group is available at http://www.cryptopp.com.
---
You received this message because you are subscribed to the Google Groups "Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PR 438: Use ::byte instead of byte

Jeffrey Walton-3
In reply to this post by Jeffrey Walton-3


On Sunday, June 18, 2017 at 3:35:10 PM UTC-4, Jeffrey Walton wrote:
...
We have a PR for "Use ::byte instead of byte", <a href="https://github.com/weidai11/cryptopp/pull/438/files" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fweidai11%2Fcryptopp%2Fpull%2F438%2Ffiles\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE1yNlYsxFyQ4C1SC58v8__YufZjA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fweidai11%2Fcryptopp%2Fpull%2F438%2Ffiles\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE1yNlYsxFyQ4C1SC58v8__YufZjA&#39;;return true;">https://github.com/weidai11/cryptopp/pull/438/files.

A supporting check-in occurred at https://github.com/weidai11/cryptopp/commit/fe637956388f. Effectively it made Kalyna and its use of byte in an anonymous namespace immune to changes going on in outer scopes.

The meat-and-potatoes check-in has not occurred yet. It should be next.

Jeff

--
--
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to [hidden email].
More information about Crypto++ and this group is available at http://www.cryptopp.com.
---
You received this message because you are subscribed to the Google Groups "Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Loading...