switch to constexpr char[] buildinfo - #2372
Conversation
03ab8de to
2fe4619
Compare
| // If this is a first run we short-circuit the address passed in | ||
| if (_firstRun.get()) { | ||
| if (!BuildInfo::PRELOADED_STARTUP_LOCATION.isEmpty()) { | ||
| if (!std::string_view(BuildInfo::PRELOADED_STARTUP_LOCATION).empty()) { |
There was a problem hiding this comment.
Why do we need to use std::string_view here, but can get away with std::empty in libraries/networking/src/AddressManager.cpp:41?
What is the difference?
There was a problem hiding this comment.
One is in constexpr, the other one isn't, which means I need to construct it here. But theoretically, both could be the same.
There was a problem hiding this comment.
So the difference is that here we just want to access BuildInfo::PRELOADED_STARTUP_LOCATION, and in libraries/networking/src/AddressManager.cpp:41 we want to copy it, since the compiler does that at compile time? Does std::string_view not work at compile time, so we need to copy instead?
There was a problem hiding this comment.
std::string_view is does not make a copy. It is basically a fat pointer to a slice of memory, which is interpreted as a string. In the constructor, we are passing the char array as the thing we point to.
There was a problem hiding this comment.
ok, after some reading, I have found out that the usage of std::empty in this case is not workable, because here it is always returning false???
There was a problem hiding this comment.
Did we just run into exactly what Clang means when it says "may throw an exception that cannot be caught"?
This should stop the code checker spam in PRs.
2fe4619 to
ee13908
Compare
|
Wouldn't |
7a31709 to
ee13908
Compare
Sadly, the same error appears, which we wanted to prevent in the first place |
This should stop the code checker spam in PRs.