-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Switch to C++17 #64152
Switch to C++17 #64152
Conversation
Considering not all cpp17 features can be used; can structured binding be used? Asking both from compiler support and code style perspectives? E.g.
into |
From a compiler support perspective, yes, structured bindings are fine. From a code style perspective, I think we will probably allow them in certain situations. But since we do have the "almost always avoid At the least I hope to use them for iterating over containers of pairs, which is a super common pattern in our codebase. |
95f7e82
to
e59e817
Compare
For reference, the C++17 features which we should avoid are documented here, |
Maybe revert back to ghc file system and see if permission errors go away? |
@akrieger is hoping to test locally and see what can be done. |
I saw an instance of this in an unrelated PR yesterday and it resolved with a rerun, so at a minimum I don't think this PR is the cause. |
Good to know, thanks! |
I would appreciate it if we could resolve #64210 before merging this. (Not going to fix / dropping Debian support is totally a possible resolution - I just think it would be best to make a decision before merging additional compiler changes). |
I think the issue in #64210 should be mostly orthogonal to this, but thanks for the heads up. |
0e11b19
to
c1dc970
Compare
Same failure again, seems suspect. I scrolled through other recent failures and didn't see the same. I tested yesterday and didn't repro, but realized just now I tested with 2022, so I'm going to revert back to 2019 and try again today. |
The error is caused by the trailing diff --git a/src/filesystem.cpp b/src/filesystem.cpp
index e498da3736..d437f50470 100644
--- a/src/filesystem.cpp
+++ b/src/filesystem.cpp
@@ -21,7 +21,11 @@
bool assure_dir_exist( const std::string &path )
{
- return assure_dir_exist( fs::u8path( path ) );
+ std::string p = path;
+ if (!p.empty() && p.back() == '/') {
+ p.pop_back();
+ }
+ return assure_dir_exist( fs::u8path( p ));
}
bool assure_dir_exist( const cata_path &path ) |
[edit: apparently not this bug in the VS patch notes] I saw something related to that in the some 2019 patch notes. I believe there are many fixes listed in https://learn.microsoft.com/en-us/cpp/overview/cpp-conformance-improvements-2019?view=msvc-170 which are backports of recent standards committee meetings, including stuff about trailing slashes like mentioned in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87846 |
Specifically https://cplusplus.github.io/LWG/issue3096 is probably the relevant change. |
Thanks for the diagnosis. I've pushed a tentative fix. |
Regarding the item density test, I thought it was something like that too, but it turns out it's much more prosaic, the clang++-12 workflow is the first one that runs with magiclysm loaded, and you were hitting a magiclysm-specific data error that was fixed in #64258 |
Convert the Makefile, CMakeLists, and Visual Studio projects to use C++17.
- std::uncaught_exception is deprecated. - std::is_literal is deprecated. - Some small things in the filesystem library have changed. - [[nodiscard]] is now available, so suppress the clang-tidy check suggesting it.
A few small changes in C++17 mean that clang-tidy is now able to apply a few more fixes. Do so.
To help me debug CI issues.
7a88f13
to
6df786b
Compare
OK, I've removed the item density fix and rebased on master. Based on previous experience on this PR, the CI is going to take a long time to run (presumably because all the cached data is useless here). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of this lint shouldve been caught pre-17, no?
This header can't be relied upon to exist.
I think this is good to go, so I've removed the WIP label. |
Summary
Infrastructure "Convert build to C++17 (from C++14)"
Purpose of change
Following up on #63970 and #64011.
We want to move to C++17 to get new features and generally keep the codebase up to date.
Describe the solution
Update each of the build files to use C++17 (
Makefile
,CMakeLists.txt
, Visual Studio projects).Fix the various compiler errors and clang-tidy warnings that arise.
Describe alternatives you've considered
Waiting until #64011 was already merged.It is merged now.Testing
Unit tests, clang-tidy.
Mostly this needs to be tested on CI, so I have to open it as a non-draft, but marking it WIP because there's bound to be issues on other compilers.
Additional context