- C++20 (g++ & clang++)
- Circle (safe-cpp)
- D (extern(C++))
- Rust (legacy)
url: https://godbolt.org/z/P9EMxWveK
based on: llvm/llvm-project#62765
| /* | |
| * Based on zig std.BoundedArray from https://github.com/jedisct1/zig-bounded-array | |
| * license: MIT | |
| */ | |
| module bounded_array; | |
| import core.stdc.string : memcpy, memmove; | |
| /** |
| /* | |
| * @author: kassane <[email protected]> | |
| * license: MIT | |
| * build cmd: g++ asio_snmp.cc -o asnmp -std=c++23 -O2 -pthread -I$HOME/asio/asio/include $(net-snmp-config --cflags) $(net-snmp-config --libs) | |
| * config-test doc: https://wiki.archlinux.org/title/Snmpd | |
| */ | |
| #include <asio.hpp> | |
| #include <net-snmp/net-snmp-config.h> | |
| #include <net-snmp/net-snmp-includes.h> |
| #include <assert.h> | |
| #include <stddef.h> | |
| #include <stdio.h> | |
| #include <stdalign.h> | |
| #pragma pack(push, 4) | |
| struct vm_region_submap_short_info_64 { | |
| int protection; | |
| int max_protection; | |
| unsigned int inheritance; |
| /+ | |
| + License: ISC | |
| + | |
| + Ref.: | |
| + * https://github.com/camblomquist/loop-recognition-bench | |
| + * https://github.com/hundt98847/multi-language-bench | |
| + * https://blomqu.ist/posts/2025/loop-recognition/ | |
| + | |
| +/ | |
| // source/app.d |
| /** | |
| License: CC0 | |
| author: Matheus C. França | |
| requires: https://github.com/pavel-kirienko/o1heap - credits: pavel-kirienko | |
| */ | |
| #include <stdio.h> | |
| #include <stdint.h> | |
| #include <stddef.h> | |
| #include <assert.h> | |
| #include <o1heap.h> |
url: https://godbolt.org/z/P9EMxWveK
based on: llvm/llvm-project#62765
| // Works in betterC mode (tested on: ldc2 & opend-ldc2) | |
| module arena; | |
| struct Arena | |
| { | |
| void* start; | |
| size_t used; | |
| size_t capacity; | |
| static scope Arena* create(size_t capacity) |
| const std = @import("std"); | |
| const math = std.math; | |
| const assert = std.debug.assert; | |
| const testing = std.testing; | |
| pub const Policy = struct { | |
| pub const SignPolicy = enum { | |
| return_sign, | |
| ignore_sign, | |
| }; |
| issue | c | zig (release-safe) | rust (release) | Nim (release) | Nim (danger) | D (@safe) | Swift | modern C++ |
|---|---|---|---|---|---|---|---|---|
| out-of-bounds heap read/write | none | runtime | runtime | runtime | none | runtime | runtime | none³ |
| null pointer dereference | none | runtime | runtime | runtime | none | runtime¹ | runtime | none⁴ |
| type confusion | none | runtime, partial | runtime | compile time | compile time | compile time | compile time | partial⁵ |
| integer overflow | none | runtime | runtime | runtime | none | wraps | runtime (checked) | undefined behavior |
| use after free | none | none |
| //! Zig v0.13.0 or master | |
| //! Recommended `-Doptimize=ReleaseSmall` or `-Doptimize=ReleaseFast` (disabling sanitizer) | |
| const std = @import("std"); | |
| pub fn build(b: *std.Build) void { | |
| const target = b.standardTargetOptions(.{}); | |
| const optimize = b.standardOptimizeOption(.{}); | |
| // -Duse_tb | |
| const use_tb = b.option(bool, "use_tb", "Enable the tild backend") orelse false; |