Comments (16)
So, I've tried multiple times to fix the MSVC warning for <expected>
, but older versions of Clang break with these kinds of checks. If you're able to make a pull request that passes, that would be great, but otherwise we've just been living with these warnings and they'll go away in C++23 and beyond.
Yeah, boost-ut
has some major issues. I've been trying to get them to fix some random segfaults from simply including the header. I've developed a simpler ut library that matches the core API of boost-ut that I will probably switch over to.
from glaze.
Clang 15 should build. I run actions with 16, 17, & 18
from glaze.
I'll take another look at whether I should refactor the code or just locally disable the warning. Thanks for pointing these out.
from glaze.
Yeah, I saw those. Working on them now.
from glaze.
To explain a bit more why avoiding unreachable is a challenge:
If Glaze were to use exceptions we could easily make local lambda functions that wrap up behavior and then just call these functions in the appropriate if constexpr
branches. However, because Glaze does not use exceptions internally any lambda function breaks our ability to return from the function at hand, we just return from the lambda. This requires an additional error check after the lambda is called, to determine if an error occurred in the lambda, instead of just exiting from the function. So, we lose performance by using lambdas.
This is a problem that requires deterministic and non-allocating exception support in C++. There have been proposals to improve exception handling in C++, but I think the broader community needs to see this as more of a critical issue.
from glaze.
I just merged in #1039, which removes most the warnings across the compilers.
from glaze.
I'm moving to a new version of ut to avoid issues in the library, which should solve the problem seen in the jsonrpc tests. In #1041
from glaze.
Thanks for sharing. Most of these warnings are from Eigen or asio, but I did spot one potential under-read issue for glaze flags, which I'll look into.
Could you point me to the cases of the sporadic error in jsonrpc_test
on Windows?
Glaze also runs CI on a bunch of platforms and configurations under its GitHub Actions. But, your CI tests show that I should probably also be build testing with the c++26
flag where possible.
from glaze.
Yep, and especially MSVC complains about a few things. One is the use of <expected>
with #if __has_include(<expected>)
which should instead be checked something like this:
#ifdef __has_include
# if __has_include(<version>)
# include <version> // bring in feature-macros
# endif
#endif
#if __cpp_expected >= 202202L
# include <expected>
#endif
Could you point me to the cases of the sporadic error in jsonrpc_test on Windows?
That would be jsonrpc_test.cpp:43
with test_name = response:{"jsonrpc":"2.0","result":6,"id":1}
. But I can see that it crashes inside ut.hpp:1674
:
ss.str()
is not popping because '@
Edit.
This is with boost-ut v2.0.1
.
Also, this test should have exceptions turned off (I think), but it just hits std::abort()
in that case.
from glaze.
What is the oldest Clang version you support?
from glaze.
And just since I had them pop up right now (I build with -W4
):
glaze\json\read.hpp(2287) : warning C4702: unreachable code
glaze\json\read.hpp(2289) : warning C4702: unreachable code
glaze\json\read.hpp(2292) : warning C4702: unreachable code
glaze\json\read.hpp(2293) : warning C4702: unreachable code
glaze\json\read.hpp(2296) : warning C4702: unreachable code
glaze\json\read.hpp(2297) : warning C4702: unreachable code
glaze\json\read.hpp(2308) : warning C4702: unreachable code
glaze\json\read.hpp(2312) : warning C4702: unreachable code
glaze\json\read.hpp(2315) : warning C4702: unreachable code
from glaze.
Unreachable code is annoying to deal with in Glaze because it often means needing to duplicate code (because of so many if constexpr
branches), and the compiler will typically simply remove unreachable code. I'm wondering if I should just disable these warnings locally?
from glaze.
You could probably just be explicit with std::unreachable()
.
That is, define a macro GLZ_UNREACHABLE
if #if defined(__cpp_lib_unreachable) && __cpp_lib_unreachable >= 202202L
.
from glaze.
Yeah, Glaze uses a bit of unreachable
. The problem in these cases is that the code is conditionally unreachable. I can use an if constexpr
check to throw in an unreachable
when that would be the case, but the compiler will still complain that the rest of the code is unreachable, so std::unreachable
doesn't actually improve anything.
This is typically a problem with constexpr conditional tail/end behavior.
from glaze.
Ok I see. Well, I'll just disable that warning (/w4702
) for the tests in my build2
package. Don't think I've seen it in my own project consuming glaze
.
from glaze.
While we're at it with MSVC (unless you already saw this warning):
read.hpp(36): warning C4244: 'argument': conversion from 'const int' to 'const uint8_t', possible loss of data
when compiling tests\binary_test\binary_test.cpp(1284)
(probably a few others as well).
from glaze.
Related Issues (20)
- calculate serialize size before serialization and serialize to pre-allocated memory HOT 4
- Option to use partial with char* or char[] HOT 7
- data_must_be_null_terminated issue HOT 4
- Raw char buffer handling HOT 2
- Built-in support for type control HOT 3
- reflection fails with custom serializer for std::chrono types on clang/gcc HOT 7
- How do I write an enum as a raw string? HOT 1
- compile error with error_on_missing_keys HOT 1
- old GCC 11.4.0 compiler support HOT 8
- Link to NDJSON website looks sus... HOT 2
- [ICE] `msvc 17.8` (`glaze 2.8.1`) HOT 1
- Numeric variant deduction type
- Write_binary/read_binary support for the "json_t" interface HOT 6
- is_[json_type] concepts in glz:: namespace
- Compilation error when structure have more than 32 fields HOT 1
- How to pass glz::read_json to a std::function? HOT 1
- Support std::variant<...,std::variant<...> > HOT 2
- repe::registry needs to handle throws on function calls
- Tuple routines not working as expected HOT 1
- Does glaze handle structs with static members ? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from glaze.