Thanks for using Compiler Explorer
Sponsors
Jakt
C++
Ada
Algol68
Analysis
Android Java
Android Kotlin
Assembly
C
C3
Carbon
C with Coccinelle
C++ with Coccinelle
C++ (Circle)
CIRCT
Clean
CMake
CMakeScript
COBOL
C++ for OpenCL
MLIR
Cppx
Cppx-Blue
Cppx-Gold
Cpp2-cppfront
Crystal
C#
CUDA C++
D
Dart
Elixir
Erlang
Fortran
F#
GLSL
Go
Haskell
HLSL
Hook
Hylo
IL
ispc
Java
Julia
Kotlin
LLVM IR
LLVM MIR
Modula-2
Mojo
Nim
Numba
Nix
Objective-C
Objective-C++
OCaml
Odin
OpenCL C
Pascal
Pony
PTX
Python
Racket
Raku
Ruby
Rust
Sail
Snowball
Scala
Slang
Solidity
Spice
SPIR-V
Swift
LLVM TableGen
Toit
Triton
TypeScript Native
V
Vala
Visual Basic
Vyper
WASM
Zig
Javascript
GIMPLE
Ygen
sway
crystal source #1
Output
Compile to binary object
Link to binary
Execute the code
Intel asm syntax
Demangle identifiers
Verbose demangling
Filters
Unused labels
Library functions
Directives
Comments
Horizontal whitespace
Debug intrinsics
Compiler
Crystal 0.29.0
Crystal 0.30.1
Crystal 0.31.1
Crystal 0.32.1
Crystal 0.33.0
Crystal 0.34.0
Crystal 0.35.1
Crystal 0.36.1
Crystal 1.0.0
Crystal 1.1.1
Crystal 1.10.1
Crystal 1.11.1
Crystal 1.12.2
Crystal 1.13.3
Crystal 1.14.1
Crystal 1.15.1
Crystal 1.16.3
Crystal 1.17.0
Crystal 1.2.2
Crystal 1.3.2
Crystal 1.4.1
Crystal 1.5.1
Crystal 1.6.2
Crystal 1.7.3
Crystal 1.8.2
Crystal 1.9.2
Options
Source code
require "lib_c" lib LibC fun printf(fmt : LibC::Char*, ...) : LibC::Int end class String def to_unsafe pointerof(@c) end end struct StaticArray(T, N) def to_unsafe : T* pointerof(@buffer) end def []=(index : Int, value : T) : T (to_unsafe + index.to_i64!).value = value value end end lib LibIntrinsics fun memset = "llvm.memset.p0.i64"(dest : Void*, val : UInt8, len : UInt64, is_volatile : Bool) end fun foo_insecure password = uninitialized UInt8[4] password[0] = 0x61 password[1] = 0x62 password[2] = 0x63 password[3] = 0x00 LibC.printf("%s\n", password) LibIntrinsics.memset(password.to_unsafe, 0, 4, false) end fun foo password = uninitialized UInt8[4] password[0] = 0x64 password[1] = 0x65 password[2] = 0x66 password[3] = 0x00 LibC.printf("%s\n", password) LibIntrinsics.memset(password.to_unsafe, 0, 4, true) end foo_insecure foo
Become a Patron
Sponsor on GitHub
Donate via PayPal
Compiler Explorer Shop
Source on GitHub
Mailing list
Installed libraries
Wiki
Report an issue
How it works
Contact the author
CE on Mastodon
CE on Bluesky
Statistics
Changelog
Version tree