mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Fixes slicing with negative value error message - llvm_codegen_expr.c (#2410)
* Fixes slicing with negative value error message - llvm_codegen_expr.c
Fixes printing negative value
Example:
```
fn void main()
{
int[100] arr;
usz a = 35;
usz b = 36;
arr[b:a - b];
}
```
output should be:
ERROR: 'Negative value (-1) given for slice length.'
* Update releasenotes.
---------
Co-authored-by: Christoffer Lerno <christoffer@aegik.com>
This commit is contained in:
@@ -50,6 +50,7 @@
|
|||||||
- Miscompilation of do-while when the while starts with a branch #2394.
|
- Miscompilation of do-while when the while starts with a branch #2394.
|
||||||
- Compiler assert when calling unassigned CT functions #2418.
|
- Compiler assert when calling unassigned CT functions #2418.
|
||||||
- Fixed crash in header generation when exporting functions with const enums (#2384).
|
- Fixed crash in header generation when exporting functions with const enums (#2384).
|
||||||
|
- Fix incorrect panic message when slicing with negative size.
|
||||||
|
|
||||||
### Stdlib changes
|
### Stdlib changes
|
||||||
- Add `==` to `Pair`, `Triple` and TzDateTime. Add print to `Pair` and `Triple`.
|
- Add `==` to `Pair`, `Triple` and TzDateTime. Add print to `Pair` and `Triple`.
|
||||||
|
|||||||
@@ -2791,6 +2791,7 @@ static void llvm_emit_slice_values(GenContext *c, Expr *slice, BEValue *parent_r
|
|||||||
llvm_emit_int_comp(c, &excess, &start_index, &end_index, BINARYOP_GT);
|
llvm_emit_int_comp(c, &excess, &start_index, &end_index, BINARYOP_GT);
|
||||||
BEValue actual_end_len = end_index;
|
BEValue actual_end_len = end_index;
|
||||||
actual_end_len.value = llvm_emit_sub_int(c, end_index.type, end_index.value, start_index.value, slice->span);
|
actual_end_len.value = llvm_emit_sub_int(c, end_index.type, end_index.value, start_index.value, slice->span);
|
||||||
|
actual_end_len.type = type_isz;
|
||||||
llvm_emit_panic_if_true(c, &excess, "Negative slice length", slice->span, "Negative value (%d) given for slice length.", &actual_end_len, NULL);
|
llvm_emit_panic_if_true(c, &excess, "Negative slice length", slice->span, "Negative value (%d) given for slice length.", &actual_end_len, NULL);
|
||||||
if (len.value)
|
if (len.value)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user