Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

builtin: remove string interpolation from panic/1, to be able to use tools like cbmc in more cases #22182

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions vlib/builtin/builtin.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,14 @@ pub fn panic_result_not_set(s string) {
// It also shows a backtrace on most platforms.
@[noreturn]
pub fn panic(s string) {
// Note: be careful to not use string interpolation here:
$if freestanding {
bare_panic(s)
} $else {
eprint('V panic: ')
eprintln(s)
eprintln('v hash: ${@VCURRENTHASH}')
eprint('v hash: ')
eprintln(@VCURRENTHASH)
$if native {
C.exit(1) // TODO: native backtraces
} $else $if exit_after_panic_message ? {
Expand Down Expand Up @@ -155,7 +157,7 @@ pub fn panic(s string) {
pub fn c_error_number_str(errnum int) string {
mut err_msg := ''
$if freestanding {
err_msg = 'error ${errnum}'
err_msg = 'error ' + errnum.str()
} $else {
$if !vinix {
c_msg := C.strerror(errnum)
Expand Down
Loading