mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
compiler: "illegal behavior", not "undefined behavior", in errors
This commit is contained in:
parent
ca1fc3827e
commit
eee752ea5a
30
src/Air.zig
30
src/Air.zig
@ -37,7 +37,7 @@ pub const Inst = struct {
|
||||
/// liveness analysis without any special handling.
|
||||
/// Uses the `arg` field.
|
||||
arg,
|
||||
/// Float or integer addition. For integers, wrapping is undefined behavior.
|
||||
/// Float or integer addition. For integers, wrapping is illegal behavior.
|
||||
/// Both operands are guaranteed to be the same type, and the result type
|
||||
/// is the same as both operands.
|
||||
/// Uses the `bin_op` field.
|
||||
@ -66,7 +66,7 @@ pub const Inst = struct {
|
||||
/// is the same as both operands.
|
||||
/// Uses the `bin_op` field.
|
||||
add_sat,
|
||||
/// Float or integer subtraction. For integers, wrapping is undefined behavior.
|
||||
/// Float or integer subtraction. For integers, wrapping is illegal behavior.
|
||||
/// Both operands are guaranteed to be the same type, and the result type
|
||||
/// is the same as both operands.
|
||||
/// Uses the `bin_op` field.
|
||||
@ -95,7 +95,7 @@ pub const Inst = struct {
|
||||
/// is the same as both operands.
|
||||
/// Uses the `bin_op` field.
|
||||
sub_sat,
|
||||
/// Float or integer multiplication. For integers, wrapping is undefined behavior.
|
||||
/// Float or integer multiplication. For integers, wrapping is illegal behavior.
|
||||
/// Both operands are guaranteed to be the same type, and the result type
|
||||
/// is the same as both operands.
|
||||
/// Uses the `bin_op` field.
|
||||
@ -131,14 +131,14 @@ pub const Inst = struct {
|
||||
div_float,
|
||||
/// Same as `div_float` with optimized float mode.
|
||||
div_float_optimized,
|
||||
/// Truncating integer or float division. For integers, wrapping is undefined behavior.
|
||||
/// Truncating integer or float division. For integers, wrapping is illegal behavior.
|
||||
/// Both operands are guaranteed to be the same type, and the result type
|
||||
/// is the same as both operands.
|
||||
/// Uses the `bin_op` field.
|
||||
div_trunc,
|
||||
/// Same as `div_trunc` with optimized float mode.
|
||||
div_trunc_optimized,
|
||||
/// Flooring integer or float division. For integers, wrapping is undefined behavior.
|
||||
/// Flooring integer or float division. For integers, wrapping is illegal behavior.
|
||||
/// Both operands are guaranteed to be the same type, and the result type
|
||||
/// is the same as both operands.
|
||||
/// Uses the `bin_op` field.
|
||||
@ -146,8 +146,8 @@ pub const Inst = struct {
|
||||
/// Same as `div_floor` with optimized float mode.
|
||||
div_floor_optimized,
|
||||
/// Integer or float division.
|
||||
/// If a remainder would be produced, undefined behavior occurs.
|
||||
/// For integers, overflow is undefined behavior.
|
||||
/// If a remainder would be produced, illegal behavior occurs.
|
||||
/// For integers, overflow is illegal behavior.
|
||||
/// Both operands are guaranteed to be the same type, and the result type
|
||||
/// is the same as both operands.
|
||||
/// Uses the `bin_op` field.
|
||||
@ -170,14 +170,14 @@ pub const Inst = struct {
|
||||
mod_optimized,
|
||||
/// Add an offset to a pointer, returning a new pointer.
|
||||
/// The offset is in element type units, not bytes.
|
||||
/// Wrapping is undefined behavior.
|
||||
/// Wrapping is illegal behavior.
|
||||
/// The lhs is the pointer, rhs is the offset. Result type is the same as lhs.
|
||||
/// The pointer may be a slice.
|
||||
/// Uses the `ty_pl` field. Payload is `Bin`.
|
||||
ptr_add,
|
||||
/// Subtract an offset from a pointer, returning a new pointer.
|
||||
/// The offset is in element type units, not bytes.
|
||||
/// Wrapping is undefined behavior.
|
||||
/// Wrapping is illegal behavior.
|
||||
/// The lhs is the pointer, rhs is the offset. Result type is the same as lhs.
|
||||
/// The pointer may be a slice.
|
||||
/// Uses the `ty_pl` field. Payload is `Bin`.
|
||||
@ -577,10 +577,10 @@ pub const Inst = struct {
|
||||
/// sign but an equal or smaller number of bits.
|
||||
/// Uses the `ty_op` field.
|
||||
trunc,
|
||||
/// ?T => T. If the value is null, undefined behavior.
|
||||
/// ?T => T. If the value is null, illegal behavior.
|
||||
/// Uses the `ty_op` field.
|
||||
optional_payload,
|
||||
/// *?T => *T. If the value is null, undefined behavior.
|
||||
/// *?T => *T. If the value is null, illegal behavior.
|
||||
/// Uses the `ty_op` field.
|
||||
optional_payload_ptr,
|
||||
/// *?T => *T. Sets the value to non-null with an undefined payload value.
|
||||
@ -589,16 +589,16 @@ pub const Inst = struct {
|
||||
/// Given a payload value, wraps it in an optional type.
|
||||
/// Uses the `ty_op` field.
|
||||
wrap_optional,
|
||||
/// E!T -> T. If the value is an error, undefined behavior.
|
||||
/// E!T -> T. If the value is an error, illegal behavior.
|
||||
/// Uses the `ty_op` field.
|
||||
unwrap_errunion_payload,
|
||||
/// E!T -> E. If the value is not an error, undefined behavior.
|
||||
/// E!T -> E. If the value is not an error, illegal behavior.
|
||||
/// Uses the `ty_op` field.
|
||||
unwrap_errunion_err,
|
||||
/// *(E!T) -> *T. If the value is an error, undefined behavior.
|
||||
/// *(E!T) -> *T. If the value is an error, illegal behavior.
|
||||
/// Uses the `ty_op` field.
|
||||
unwrap_errunion_payload_ptr,
|
||||
/// *(E!T) -> E. If the value is not an error, undefined behavior.
|
||||
/// *(E!T) -> E. If the value is not an error, illegal behavior.
|
||||
/// Uses the `ty_op` field.
|
||||
unwrap_errunion_err_ptr,
|
||||
/// *(E!T) => *T. Sets the value to non-error with an undefined payload value.
|
||||
|
||||
@ -2327,11 +2327,11 @@ fn failWithNeededComptime(sema: *Sema, block: *Block, src: LazySrcLoc, reason: ?
|
||||
}
|
||||
|
||||
pub fn failWithUseOfUndef(sema: *Sema, block: *Block, src: LazySrcLoc) CompileError {
|
||||
return sema.fail(block, src, "use of undefined value here causes undefined behavior", .{});
|
||||
return sema.fail(block, src, "use of undefined value here causes illegal behavior", .{});
|
||||
}
|
||||
|
||||
pub fn failWithDivideByZero(sema: *Sema, block: *Block, src: LazySrcLoc) CompileError {
|
||||
return sema.fail(block, src, "division by zero here causes undefined behavior", .{});
|
||||
return sema.fail(block, src, "division by zero here causes illegal behavior", .{});
|
||||
}
|
||||
|
||||
fn failWithModRemNegative(sema: *Sema, block: *Block, src: LazySrcLoc, lhs_ty: Type, rhs_ty: Type) CompileError {
|
||||
@ -15496,7 +15496,7 @@ fn zirDivExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
|
||||
}
|
||||
|
||||
// Depending on whether safety is enabled, we will have a slightly different strategy
|
||||
// here. The `div_exact` AIR instruction causes undefined behavior if a remainder
|
||||
// here. The `div_exact` AIR instruction causes illegal behavior if a remainder
|
||||
// is produced, so in the safety check case, it cannot be used. Instead we do a
|
||||
// div_trunc and check for remainder.
|
||||
|
||||
@ -25266,7 +25266,7 @@ fn ptrSubtract(sema: *Sema, block: *Block, src: LazySrcLoc, ptr_val: Value, byte
|
||||
};
|
||||
if (ptr.byte_offset < byte_subtract) {
|
||||
return sema.failWithOwnedErrorMsg(block, msg: {
|
||||
const msg = try sema.errMsg(src, "pointer computation here causes undefined behavior", .{});
|
||||
const msg = try sema.errMsg(src, "pointer computation here causes illegal behavior", .{});
|
||||
errdefer msg.destroy(sema.gpa);
|
||||
try sema.errNote(src, msg, "resulting pointer exceeds bounds of containing value which may trigger overflow", .{});
|
||||
break :msg msg;
|
||||
|
||||
@ -5,4 +5,4 @@ comptime {
|
||||
|
||||
// error
|
||||
//
|
||||
// :3:5: error: use of undefined value here causes undefined behavior
|
||||
// :3:5: error: use of undefined value here causes illegal behavior
|
||||
|
||||
@ -5,7 +5,5 @@ comptime {
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :4:9: error: use of undefined value here causes undefined behavior
|
||||
// :4:9: error: use of undefined value here causes illegal behavior
|
||||
|
||||
@ -4,7 +4,5 @@ export fn entry1() void {
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :2:41: error: use of undefined value here causes undefined behavior
|
||||
// :2:41: error: use of undefined value here causes illegal behavior
|
||||
|
||||
@ -5,7 +5,5 @@ export fn entry() usize {
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :1:15: error: use of undefined value here causes undefined behavior
|
||||
// :1:15: error: use of undefined value here causes illegal behavior
|
||||
|
||||
@ -4,7 +4,5 @@ comptime {
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :3:11: error: use of undefined value here causes undefined behavior
|
||||
// :3:11: error: use of undefined value here causes illegal behavior
|
||||
|
||||
@ -8,5 +8,5 @@ export fn bar(x: u32) void {
|
||||
|
||||
// error
|
||||
//
|
||||
// :2:11: error: use of undefined value here causes undefined behavior
|
||||
// :6:11: error: use of undefined value here causes undefined behavior
|
||||
// :2:11: error: use of undefined value here causes illegal behavior
|
||||
// :6:11: error: use of undefined value here causes illegal behavior
|
||||
|
||||
@ -36,12 +36,10 @@ comptime {
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :5:11: error: use of undefined value here causes undefined behavior
|
||||
// :11:11: error: use of undefined value here causes undefined behavior
|
||||
// :17:11: error: use of undefined value here causes undefined behavior
|
||||
// :23:11: error: use of undefined value here causes undefined behavior
|
||||
// :29:11: error: use of undefined value here causes undefined behavior
|
||||
// :35:11: error: use of undefined value here causes undefined behavior
|
||||
// :5:11: error: use of undefined value here causes illegal behavior
|
||||
// :11:11: error: use of undefined value here causes illegal behavior
|
||||
// :17:11: error: use of undefined value here causes illegal behavior
|
||||
// :23:11: error: use of undefined value here causes illegal behavior
|
||||
// :29:11: error: use of undefined value here causes illegal behavior
|
||||
// :35:11: error: use of undefined value here causes illegal behavior
|
||||
|
||||
@ -6,7 +6,5 @@ comptime {
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :4:19: error: division by zero here causes undefined behavior
|
||||
// :4:19: error: division by zero here causes illegal behavior
|
||||
|
||||
@ -6,7 +6,5 @@ comptime {
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :4:19: error: division by zero here causes undefined behavior
|
||||
// :4:19: error: division by zero here causes illegal behavior
|
||||
|
||||
@ -8,8 +8,6 @@ export fn entry() usize {
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :3:16: error: division by zero here causes undefined behavior
|
||||
// :3:16: error: division by zero here causes illegal behavior
|
||||
// :1:14: note: called from here
|
||||
|
||||
@ -6,7 +6,5 @@ comptime {
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :3:32: error: use of undefined value here causes undefined behavior
|
||||
// :3:32: error: use of undefined value here causes illegal behavior
|
||||
|
||||
@ -5,4 +5,4 @@ comptime {
|
||||
|
||||
// error
|
||||
//
|
||||
// :3:5: error: use of undefined value here causes undefined behavior
|
||||
// :3:5: error: use of undefined value here causes illegal behavior
|
||||
|
||||
@ -17,9 +17,7 @@ export fn entry4() usize {
|
||||
} // no error on purpose
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :1:23: error: division by zero here causes undefined behavior
|
||||
// :2:27: error: division by zero here causes undefined behavior
|
||||
// :3:29: error: division by zero here causes undefined behavior
|
||||
// :1:23: error: division by zero here causes illegal behavior
|
||||
// :2:27: error: division by zero here causes illegal behavior
|
||||
// :3:29: error: division by zero here causes illegal behavior
|
||||
|
||||
@ -4,7 +4,5 @@ comptime {
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :3:10: error: use of undefined value here causes undefined behavior
|
||||
// :3:10: error: use of undefined value here causes illegal behavior
|
||||
|
||||
@ -7,7 +7,5 @@ export fn foo() void {
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :4:28: error: use of undefined value here causes undefined behavior
|
||||
// :4:28: error: use of undefined value here causes illegal behavior
|
||||
|
||||
@ -4,7 +4,5 @@ comptime {
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :3:5: error: use of undefined value here causes undefined behavior
|
||||
// :3:5: error: use of undefined value here causes illegal behavior
|
||||
|
||||
@ -5,7 +5,5 @@ comptime {
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :3:9: error: use of undefined value here causes undefined behavior
|
||||
// :3:9: error: use of undefined value here causes illegal behavior
|
||||
|
||||
@ -5,4 +5,4 @@ comptime {
|
||||
|
||||
// error
|
||||
//
|
||||
// :3:5: error: use of undefined value here causes undefined behavior
|
||||
// :3:5: error: use of undefined value here causes illegal behavior
|
||||
|
||||
@ -4,7 +4,5 @@ comptime {
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :3:10: error: use of undefined value here causes undefined behavior
|
||||
// :3:10: error: use of undefined value here causes illegal behavior
|
||||
|
||||
@ -5,7 +5,5 @@ comptime {
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :4:9: error: use of undefined value here causes undefined behavior
|
||||
// :4:9: error: use of undefined value here causes illegal behavior
|
||||
|
||||
@ -4,7 +4,5 @@ comptime {
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :3:11: error: use of undefined value here causes undefined behavior
|
||||
// :3:11: error: use of undefined value here causes illegal behavior
|
||||
|
||||
@ -13,7 +13,7 @@ export fn entry2() void {
|
||||
|
||||
// error
|
||||
//
|
||||
// :4:13: error: pointer computation here causes undefined behavior
|
||||
// :4:13: error: pointer computation here causes illegal behavior
|
||||
// :4:13: note: resulting pointer exceeds bounds of containing value which may trigger overflow
|
||||
// :10:55: error: pointer computation here causes undefined behavior
|
||||
// :10:55: error: pointer computation here causes illegal behavior
|
||||
// :10:55: note: resulting pointer exceeds bounds of containing value which may trigger overflow
|
||||
|
||||
@ -5,7 +5,5 @@ export fn entry() void {
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :4:6: error: use of undefined value here causes undefined behavior
|
||||
// :4:6: error: use of undefined value here causes illegal behavior
|
||||
|
||||
@ -11,7 +11,5 @@ export fn entry() void {
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :1:20: error: use of undefined value here causes undefined behavior
|
||||
// :1:20: error: use of undefined value here causes illegal behavior
|
||||
|
||||
@ -6,7 +6,5 @@ comptime {
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :1:20: error: use of undefined value here causes undefined behavior
|
||||
// :1:20: error: use of undefined value here causes illegal behavior
|
||||
|
||||
@ -25,9 +25,7 @@ comptime {
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :2:16: error: use of undefined value here causes undefined behavior
|
||||
// :5:16: error: use of undefined value here causes undefined behavior
|
||||
// :17:16: error: use of undefined value here causes undefined behavior
|
||||
// :2:16: error: use of undefined value here causes illegal behavior
|
||||
// :5:16: error: use of undefined value here causes illegal behavior
|
||||
// :17:16: error: use of undefined value here causes illegal behavior
|
||||
|
||||
@ -4,7 +4,5 @@ export fn a() void {
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :3:18: error: use of undefined value here causes undefined behavior
|
||||
// :3:18: error: use of undefined value here causes illegal behavior
|
||||
|
||||
@ -5,4 +5,4 @@ comptime {
|
||||
|
||||
// error
|
||||
//
|
||||
// :3:5: error: use of undefined value here causes undefined behavior
|
||||
// :3:5: error: use of undefined value here causes illegal behavior
|
||||
|
||||
@ -6,7 +6,5 @@ export fn entry() void {
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :3:5: error: use of undefined value here causes undefined behavior
|
||||
// :3:5: error: use of undefined value here causes illegal behavior
|
||||
|
||||
@ -5,4 +5,4 @@ comptime {
|
||||
|
||||
// error
|
||||
//
|
||||
// :3:18: error: use of undefined value here causes undefined behavior
|
||||
// :3:18: error: use of undefined value here causes illegal behavior
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -7,7 +7,5 @@ export fn entry1() void {
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :2:8: error: use of undefined value here causes undefined behavior
|
||||
// :2:8: error: use of undefined value here causes illegal behavior
|
||||
|
||||
@ -3,7 +3,5 @@ pub export fn entry() void {
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :2:31: error: use of undefined value here causes undefined behavior
|
||||
// :2:31: error: use of undefined value here causes illegal behavior
|
||||
|
||||
@ -10,7 +10,5 @@ export fn entry() void {
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :9:8: error: use of undefined value here causes undefined behavior
|
||||
// :9:8: error: use of undefined value here causes illegal behavior
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user