static int64_t val_signed(conststruct type_descriptor* type,
value_handle_t val) { if (type_is_inline(type)) { /* Sign extend if smaller than ssize_t-bits */
size_t undefined_bits = sizeof(size_t) * 8 - type_width_bits(type);
val <<= undefined_bits;
ssize_t out = (ssize_t)val;
out >>= undefined_bits; return out;
} else { /* *Thistruncates,butwedon'thaveagoodwaytodealwith *intslargerthan64bitsanditatleastgets*some*data. * *Forvalueslargerthan64bits,thiswillalsohavethewrong *sign.
*/ return *(int64_t*)val;
}
}
static uint64_t val_unsigned(conststruct type_descriptor* type,
value_handle_t val) { if (type_is_inline(type)) { return (uint64_t)val;
} else { /* This truncates, but gets some data out */ return *(uint64_t*)val;
}
}
render_val(rendered_val, sizeof(rendered_val), data->type, val);
scnprintf(details, sizeof(details), "negation of %s cannot be represented in type %s", rendered_val,
data->type->name);
intptr_t alignment = 1 << data->log_alignment; if (!ptr) {
scnprintf(details, sizeof(details), "%s null pointer type %s",
type_check_kinds[data->type_check_kind], data->type->name);
} elseif (ptr & (alignment - 1)) {
snprintf_filtered(
details, sizeof(details), "%s misaligned pointer %p for type %s which requires %d byte alignment",
type_check_kinds[data->type_check_kind], (void*)ptr,
data->type->name, (int)alignment);
} else {
snprintf_filtered(
details, sizeof(details), "%s pointer %p points at a region with insufficient space for a value of type %s",
type_check_kinds[data->type_check_kind], (void*)ptr,
data->type->name);
}
log(&data->loc, "type mismatch", details);
UBSAN_FINISH;
}
UBSAN_HANDLER(builtin_unreachable, struct unreachable_data* data) {
UBSAN_START;
log(&data->loc, "hit a supposedly unreachable point", "");
UBSAN_FINISH;
ubsan_fail("executing through unreachable would be unwise");
}
UBSAN_HANDLER(missing_return, struct unreachable_data* data) {
UBSAN_START;
log(&data->loc, "hit a missing return statement", "");
UBSAN_FINISH;
ubsan_fail("executing past the end of a function would be unwise");
}
if (is_negative(data->rhs_type, rhs)) {
scnprintf(details, sizeof(details), "shift amount is negative: %s",
rendered_rhs);
} elseif (type_width_bits(data->lhs_type) < rhs_u64) {
scnprintf(details, sizeof(details), "shift amount %s is too large for type %s", rendered_rhs,
data->lhs_type->name);
} elseif (is_negative(data->lhs_type, lhs)) { /* At this point, we know we are dealing with a left shift, as right
* shift is covered by the above two cases */
scnprintf(details, sizeof(details), "left shifting a negative value: %s", rendered_lhs);
} else {
scnprintf(details, sizeof(details), "%s << %s does not fit in %s",
rendered_lhs, rendered_rhs, data->lhs_type->name);
}
log(&data->loc, "shift out of bounds", details);
UBSAN_FINISH;
}
render_val(rendered_index, sizeof(rendered_index), data->index_type, index);
scnprintf(details, sizeof(details), "index %s out of bounds for %s\n",
rendered_index, data->array_type->name);
log(&data->loc, "out of bounds access", details);
UBSAN_FINISH;
}
render_val(rendered_val, sizeof(rendered_val), data->type, val);
scnprintf(details, sizeof(details), "load of value %s outside of range for type %s", rendered_val,
data->type->name);
UBSAN_HANDLER(float_cast_overflow, struct float_cast_overflow_data* data,
value_handle_t val) {
UBSAN_START; /* Since we aren't rendering floats, there's not much point in details */
log(&data->loc, "float cast overflow", "");
UBSAN_FINISH;
}
if (location_is_valid(data->assumption_loc)) {
log(&data->assumption_loc, "alignment assumption was specified here", /* Details: */ "below");
}
if (!offset) {
scnprintf(details, sizeof(details), "assumption of %" PRIuPTR " byte alignment for pointer of type %s failed",
alignment, data->type->name);
} else {
scnprintf(details, sizeof(details), "assumption of %" PRIuPTR " byte alignment (with offset of %" PRIuPTR " bytes) for pointer of type %s failed",
alignment, offset, data->type->name);
}
log(&data->loc, "alignment assumption is incorrect", details);
UBSAN_FINISH;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.5 Sekunden
(vorverarbeitet am 2026-06-27)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.