-fbounds-safety: Enforcing bounds safety for C
clang.llvm.org
-fbounds-safety: Enforcing bounds safety for C
1–10 of 129 posts
Re: -fbounds-safety: Enforcing bounds safety for C
#2OpenBSD maybe? or a fork of CheriBSD?
macOS clang has supported -fbounds-safety for a while, but I"m not sure how extensively it is used.
Re: -fbounds-safety: Enforcing bounds safety for C
#3I want an OS distro where all C code is compiled this way. OpenBSD maybe? or a fork of CheriBSD? macOS clang has supported -fbounds-safety for a while, but I"m not sure how extensively it is used.
You first have to modify "all C code". It's not just a set and forget compiler flag.
Re: -fbounds-safety: Enforcing bounds safety for C
#4I want an OS distro where all C code is compiled this way. OpenBSD maybe? or a fork of CheriBSD? macOS clang has supported -fbounds-safety for a while, but I"m not sure how extensively it is used.
Note that corresponding checks for C++ library containers can be enabled without modifying the source. Google measured some very small overhead ([1] https://libcxx.llvm.org/Hardening.html
Re: -fbounds-safety: Enforcing bounds safety for C
#5I want an OS distro where all C code is compiled this way. OpenBSD maybe? or a fork of CheriBSD? macOS clang has supported -fbounds-safety for a while, but I"m not sure how extensively it is used.
Re: -fbounds-safety: Enforcing bounds safety for C
#6I want an OS distro where all C code is compiled this way. OpenBSD maybe? or a fork of CheriBSD? macOS clang has supported -fbounds-safety for a while, but I"m not sure how extensively it is used.
Re: -fbounds-safety: Enforcing bounds safety for C
#7 template
struct Slice {
T* data = nullptr;
size_t size = nullptr;
T& operator[](size_t index) {
if (index >= size) crash_the_program();
return data[index];
}
};
If you're considering this extension, just use C++ and 5 lines of standard, portable, no-weird-annotations code instead.Re: -fbounds-safety: Enforcing bounds safety for C
#8template struct Slice { T* data = nullptr; size_t size = nullptr; T& operator[](size_t index) { if (index >= size) crash_the_program(); return data[index]; } }; If you're considering this extension, just use C++ and 5 lines of standard, portable, no-weird-annotations code instead.
Re: -fbounds-safety: Enforcing bounds safety for C
#9template struct Slice { T* data = nullptr; size_t size = nullptr; T& operator[](size_t index) { if (index >= size) crash_the_program(); return data[index]; } }; If you're considering this extension, just use C++ and 5 lines of standard, portable, no-weird-annotations code instead.
and if you write directly in assembly you don't even need a C++ compiler
Re: -fbounds-safety: Enforcing bounds safety for C
#10template struct Slice { T* data = nullptr; size_t size = nullptr; T& operator[](size_t index) { if (index >= size) crash_the_program(); return data[index]; } }; If you're considering this extension, just use C++ and 5 lines of standard, portable, no-weird-annotations code instead.
However, you still need something like -fbounds-safety in C++, due to the copy-paste compatibility with C, and too many people writing Orthodox C++, C with Classes, Better C, kind of code, that we cannot get rid of.