mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Fix of int.min incorrect behaviour #1154.
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
- Fixed array calculation for npot2 vectors.
|
||||
- $$memcpy_inline and $$memset_inline fixed.
|
||||
- `.$Type = ...` and `.$foo = ...` now works #1156.
|
||||
- `int.min` incorrect behaviour #1154.
|
||||
|
||||
### Stdlib changes
|
||||
- Added `new_aligned` and `alloc_aligned` functions to prevent accidental under-alignment when allocating simd.
|
||||
|
||||
@@ -3403,16 +3403,16 @@ static inline bool sema_create_const_min(SemaContext *context, Expr *expr, Type
|
||||
switch (flat->type_kind)
|
||||
{
|
||||
case TYPE_I8:
|
||||
expr->const_expr.ixx.i = (Int128){ 0, 0x80 };
|
||||
expr->const_expr.ixx.i = (Int128){ 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFF80 };
|
||||
break;
|
||||
case TYPE_I16:
|
||||
expr->const_expr.ixx.i = (Int128){ 0, 0x8000 };
|
||||
expr->const_expr.ixx.i = (Int128){ 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFF8000 };
|
||||
break;
|
||||
case TYPE_I32:
|
||||
expr->const_expr.ixx.i = (Int128){ 0, 1ULL << 31 };
|
||||
expr->const_expr.ixx.i = (Int128){ 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFF80000000 };
|
||||
break;
|
||||
case TYPE_I64:
|
||||
expr->const_expr.ixx.i = (Int128){ 0, 1ULL << 63 };
|
||||
expr->const_expr.ixx.i = (Int128){ 0xFFFFFFFFFFFFFFFF, 1ULL << 63 };
|
||||
break;
|
||||
case TYPE_I128:
|
||||
expr->const_expr.ixx.i = (Int128){ 1ULL << 63, 0 };
|
||||
|
||||
9
test/unit/regression/int_min.c3
Normal file
9
test/unit/regression/int_min.c3
Normal file
@@ -0,0 +1,9 @@
|
||||
fn void! int_min() @test
|
||||
{
|
||||
assert(int.min == -2147483648);
|
||||
assert((float)int.min == -2147483648.0f);
|
||||
assert(short.min == -32768);
|
||||
assert((float)short.min == -32768.0f);
|
||||
assert(ichar.min == -128);
|
||||
assert((float)ichar.min == -128.0f);
|
||||
}
|
||||
Reference in New Issue
Block a user