mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Concatenating an const empty slice with another array caused a null pointer access.
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
- Compiler allows a generic module to be declared with different parameters #1856.
|
||||
- Fix issue with `@const` where the statement `$foo = 1;` was not considered constant.
|
||||
- Const strings and bytes were not properly converted to compile time bools.
|
||||
- Concatenating an const empty slice with another array caused a null pointer access.
|
||||
|
||||
### Stdlib changes
|
||||
- Added '%h' and '%H' for printing out binary data in hexadecimal using the formatter.
|
||||
|
||||
@@ -417,6 +417,8 @@ bool sema_expr_analyse_ct_concat(SemaContext *context, Expr *concat_expr, Expr *
|
||||
continue;
|
||||
}
|
||||
ConstInitializer *init = expr_const_initializer_from_expr(single_expr);
|
||||
// Skip zero arrays from slices.
|
||||
if (!init) continue;
|
||||
if (init && init->kind != CONST_INIT_ARRAY_FULL)
|
||||
{
|
||||
ASSERT0(!init || init->type != type_untypedlist);
|
||||
|
||||
6
test/test_suite/compile_time/concat_zero_slice.c3t
Normal file
6
test/test_suite/compile_time/concat_zero_slice.c3t
Normal file
@@ -0,0 +1,6 @@
|
||||
fn int main()
|
||||
{
|
||||
char[] $res;
|
||||
$res = { '0' } +++ $res;
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user