Repository navigation
Adopt std::span for C++ backend #257
ariankordi
started this conversation in
Ideas
Replies: 1 comment 2 replies
|
We discussed that briefly in #203. Should we emit a separate C struct for spans of different type? Or expand it to two separate parameters which is the usual practice in C? |
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This C++20 feature is effectively a data reference with a size.
Although it'd be a drastic change to replace pointers with this, std::vector and std::array can be used its place for an argument so it'll probably feel at home for those who already write modern C++.
It's used by WebKit, who reports 0% performance cost (since bounds checking is optional): C++ Memory Safety in WebKit - Geoffrey Garen - C++Now 2025 - YouTube
The "unsafe buffer accesses" make up the bulk of the warnings that I've seen if I check C++-transpiled Fusion code in Clang (
-Weverything -Wno-conversion -Wno-c++98-compat) and this would probably solve most of them.(It also warns about using old C-style casts, but that can be changed easily)
Intriguingly, this would move us closer to supporting
.Lengthon array references. I think only C/OpenCL would need a workaround. That would be an even bigger change to make, but that's a different topic entirely.All reactions