-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Fix CI + new Doctest #3985
Fix CI + new Doctest #3985
Conversation
I believe you know how to fix this issue right, you just haven't had the time? It seems that it is is just a clang_tidy detecting issue. Mostly it seems to suggest to change the order to: basic_json(basic_json&& other) noexcept
: m_data(std::move(other.m_data)),
json_base_class_t(std::move(other)) But maybe you are referring to a different issue? |
I have not thought much about it. I can try tonight whether changing the order is fixing it indeed.
Yes, the other one is the actual blocker. |
3 similar comments
I have not thought much about it. I can try tonight whether changing the order is fixing it indeed.
Yes, the other one is the actual blocker. |
I have not thought much about it. I can try tonight whether changing the order is fixing it indeed.
Yes, the other one is the actual blocker. |
I have not thought much about it. I can try tonight whether changing the order is fixing it indeed.
Yes, the other one is the actual blocker. |
Oh, now I see it is:
So basically clang-tidy has made the checks stricter and you want to resolve all of these issues? Not sure why the original code had the About the previous issue, I have tried that and it didn't work. But this one works basic_json(basic_json&& other) noexcept
: json_base_class_t(std::forward<json_base_class_t>(other)),
m_data(std::move(other.m_data))
{
// check that passed value is valid
other.assert_invariant(false);
} Reading about it a bit, my understanding is that when you use |
This is a potential use after move bug, but since it's the base class type that's being passed along, it is probably okay as long as the base class doesn't do anything weird. Having said that, the current code should have the same potential use-after-move bug, because the order of the member inits doesn't actually effect the order in which the operations happen. The base class init always happens first, and then the members are initialized in declaration order.
The The |
Indeed that felt weird to me, but when I googled how to write a move constructor of a derived class, that is what was suggested. Do you know of a better guide on that topic, maybe one that explains the inner-workings.
From what I read, when you downcast and
But as a side-note, what happens to |
Nope. If that is indeed a recommended pattern, then I guess it's probably safe, as I was thinking.
It's passing
Yes.
A moved-from object is specified to be left in a valid-but-unspecified state. The object is still live, but you can't assume that any of its invariants hold. You can only safely call functions with no preconditions, unless you know the details of exactly what was done to the object during the move operation. |
Well the issue that @nlohmann found here is that in the most recent |
I was referring to my (perhaps incorrect) understanding that this code fixed the issue, and thus it was determining that the forwarded parameter was only partially-moved, so we could safely access
|
That indeed is my understanding of this as well. In principle the |
I think |
Thanks! I hope 6e74433 brings us forward. |
Alright, the Clang-Tidy warnings are gone. Now it's just https://github.com/nlohmann/json/actions/runs/5032287688/jobs/9025846237 missing...
|
It's frustrating, but I am thinking about commenting this test to finally get a green CI back. What do you think? |
Well looking at the failure state, I find it weird that it seems to have failed a genuine test. But the gcc tests did not fail. But the test environment is obscure because each one has different targets. I think the whole CI should be simplified and modernized using cmake presets instead and minimizing targets. But because this is a blocking CI I think it can be marked as experimental (reference) |
What do you mean?
I am not too happy with the CI either, but there are just too many combinations of operating systems, compilers, and checks... The current approach tries to rely less on the CI provider (we had to move from Travis CI recently), but to put as much logics as possible to files in the repo. I wonder if CMake presets help here.
I think I would rather mark the single test in Doctest as failable. |
I don't know, it feels like a slippery slope. At least this case only 1 test is the issue. But still it should be documented in an issue to discuss what's going on over there. I'll try to check with my ide to confirm what the issue is next week if you can open a separate issue about this.
Imo this should always be manually managed in the CI system
This however we can manage in the presets. But still it should be as lightweight and vanilla as possible. E.g. I design to have only separate compilers configuration (and in this case also c++ standards) as presets, but I would not create separate targets for theses.
I mean a test failed not a clang-tidy. About it being obscure, I mean that it is configured to build and test separate targets for gcc and clang. So we need to confirm if it is a clang version issue, cmake configuration issue, source issue etc. If they were alll the same target we would rule out a cmake configuration issue in most cases. |
I was wrong about Doctest as the issue is that the test does not compile in the first place... Anyway, I added a comment about this and will merge this now to finally have a green CI again. Happy to follow up. |
Same as #3978, but with recent Doctest release.