New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[C++17] Use ::byte instead of byte #438
[C++17] Use ::byte instead of byte #438
Conversation
I may need to test this change more completely. Did you happen to test it against |
Mmmh I didn't thought it would be an issue, but apparently the build with -std=gnu++03 is broken. Will fix that. |
6b60c46
to
6ed8fef
Compare
I have just updated my previous commit using this additional sed:
Now it seems to build fine with -std=gnu++03. Will try with more standards (03, 11, 14, 17, gnu++ vs c++). |
Thanks @Romain-Geissler-1A. I opened a thread on the mailing list about it: PR 438: Use ::byte instead of byte. This seems like one of things we want to see all of the options to minimize pain points for everyone. |
6ed8fef
to
790e937
Compare
The current version of the pull request with all version of standard (tested with gcc 7 only). I may give it a try to your alternative (define byte as std::byte). I didn't do it for two reasons:
|
Here is the kind of errors you have:
(this one might be solved with a cast of "value" into a "byte") It appears you do things (like arithmetic) on your "byte" type that is not allowed on "std::byte". So do you still would like to use it ? |
Yeah, this is the kind of question we need to find answers for. I think its unnatural to not be able to do math on
In some instances, we depend on the wrap to help with constant time operations. |
@Romain-Geissler-1A, @MarcelRaad, @DevJPM, @mouse07410, @denisbider, We setup a wiki page to explain the upcoming change; see std::byte. I wanted a wiki page for it because we need to tell people how to migrate their code for C++17 and the presence of We have not decided (yet) what the change is. @Romain-Geissler-1A, would you have some time to test moving Crypto++'s
I favor this approach since it seems to be most consistent with Herb Sutters position on namespaces and symbols. Also see Migrating to Namespaces in Dr. Dobbs Journal. Once you have your test results, I'm going to see where consensus lies and make the change. We will also update the wiki artcle and fill in the values for XXX and YYY:
|
The option that consist in saying to your users that there code is wrong and shall not use "using namespace std" is a bit extreme. While I definitely agree with this rule and apply it myself in my own code, you shall not tell the others which coding style they should adopt in their own project. Also, I work in a company with thousands of C++ developers, you know how things work in a company: such a change when you have millions and millions of existing C++ file is costly, which you can hardly sell to your client as added value. For me the sanest long term approach is to migrate ::byte to CryptoPP::byte. Anything declared in a CyrptoPP header shall follow this rule, since it's far too easy to conflict with someone else's names. Yet this has the drawback of being non source compatible, yet still binary compatible for your users (gcc mangles the char type, not the name CryptoPP::byte in function names). Being source incompatible is for example an issue in my company, but this is my own problem, I can handle that. You might want to ease migration this way (this is usually how we do it in my company): for people using C++17, then they have to migrate their user code from ::byte to CryptoPP::byte. People using C++17 are bleeding edge people, who should have no issue with changing their code. In C++ <= 14 I would declare ::byte as deprecated and advice people to replace ::byte by CryptoPP::byte to prepare for the upcoming C++17. That will break only people using -Werror, but these people are asking for such breakages, so I expect them to migrate their code to fix it. Others will only see deprecations warnings, but their code will still build and run fine. |
Thanks again @Romain-Geissler-1A.
Regarding Paragraph 1, I agree we should avoid setting policy for others (i.e., telling them what they should do). How about if we give them a choice. If Regarding And your observation "... [colliding] with someone else's names" is really the crux of the problem here. We had been running between the cracks by placing In my mind's eye, "[colliding] with someone else's names" is the root cause of the failure. We should stop running between the cracks, and use namespaces the way they were intended to avoid these collisions.
Regarding Paragraph 2, I agree. The library proper already works with either choice, modulo fixing Kalyna. We might be able to independently fix Kalyna by adding a
Paragraph 3 has two topics if I am parsing correctly. First is the actual migration or change, and second is a deprecated warning. Regarding the migration or change, I prefer to make it all or nothing (modulo the choice from Paragraph 1). I gave some thought to using We see this sort of break more often then expected. It often comes from mixing compilers and/or options. Here was a big pain point in the category of unexpected breaks: GCC5 and the C++11 ABI. A bunch of other ones are listed at GNUmakefile | CXX and CXXFLAGS on the wiki. Regarding the deprecated warning, I think that path is going to be tricky. We placed a deprecated warning on To be clear about the issue on the deprecated Our next release is going to be Crypto++ 6.0 (and not Crypto++ 5.6.6), so this is one of those times when we can break an ABI. I don't like the idea of doing it quickly without fair warning, but I don't think its too egregious in this case. Fedora 26 accelerated things when it shipped a compiler capable of C++17. I'm guessing GCC will be switching from I also pinged László Böszörményi, who is our Debian maintainer and packager. László is hands on, and he often feels the pressure and blow-back of our missteps. I want to get him involved to ensure distros are well represented, too. |
Regarding this statement, and hindsight being 20/20, the library probably should have done the following sometime between 5.6.3 to 5.6.5. Its too bad we did not have an orbuculum to help us along.
On the upside, we have the problem reduced to one corner case. The only problem we have not been able to contain or help with is when a user program employs both (1) |
… globally scoped byte This check-in supports Romain Geissler's work on cleaning up our use of ::byte when it collides with std::byte. Regardless of what happens, such as removing ::byte and adding CryptoPP::byte, providing the typedef here makes Kalyna immune to the outside changes. Also see Pull Request 437 and 438.
Thanks for the ping @noloader, much appreciated. Indeed, I've bitten by some Crypto++ issues. At the moment I can't upload version 5.6.5 as it breaks the ABI without a soname bump. Still, it has some functionality that the users request to have. I do wait for a new release, let it be 6.0.0 or an other. |
Thanks for your early help in identifying the issue, thanks for your help in fixing We checked in a change to address the issue. The change was to move The reason we did not use PR 438 was, it did not address the underlying problem of placing We added a wiki page on the matter at std::byte. Under the section Fixing User Programs, we offer your patch as one of the alternatives. |
Hi,
Agreed. Thank you for fixing this. Do you have any rough plans for an official release 6.0 ? |
I'd like to release in four to six weeks. I think we should wait at least a month to see what happens with the I also need to clear Issues 427 - 430. This is important for distros like Debian and Fedora. |
Hi, Do you have any new plans for the release 6.0 ? Cheers, |
Two task remain. First is OCB mode, and second is ed25519 signatures. I'm just about finished OCB mode. I might add SIV mode since they are similar and the changes made to the library for OCB mode accommodate SIV mode, too. I'm not sure about ed25519 at the moment. I started on it last year but I did not like the way the development was proceeding. I'm thinking it might not make 6.0, but I need a little more time with it before the decision is made. (I really want some safe curve support). |
Contains the commit of #437. All the rest is the conversion from "byte" to "::byte" to allow C++17 build even with "using namespace std".