Compiler segfault when using bitwise not on number literal cast to bitstruct #2373.

This commit is contained in:
Christoffer Lerno
2025-08-06 00:55:56 +02:00
parent 24c03f9800
commit 3b6d68ef21
3 changed files with 14 additions and 1 deletions

View File

@@ -19,6 +19,7 @@
- Compiler assert when using generic parameters list without any parameters. #2369
- Parsing difference between "0x00." and "0X00." literals #2371
- Fixed bug generating `$c += 1` when `$c` was derived from a pointer but behind a cast.
- Compiler segfault when using bitwise not on number literal cast to bitstruct #2373.
### Stdlib changes
- Add `==` to `Pair`, `Triple` and TzDateTime. Add print to `Pair` and `Triple`.

View File

@@ -8575,7 +8575,7 @@ static inline bool sema_expr_analyse_bit_not(SemaContext *context, Expr *expr, b
}
VALID_VEC:
if (is_bitstruct && sema_cast_const(inner))
if (is_bitstruct && sema_cast_const(inner) && expr_is_const_initializer(inner))
{
expr_replace(expr, inner);
sema_invert_bitstruct_const_initializer(expr->const_expr.initializer);

View File

@@ -0,0 +1,12 @@
// #target: macos-x64
module test;
bitstruct Foo : uint
{
bool test : 2;
}
fn int main()
{
~(Foo)2;
return 0;
}