diff --git a/releasenotes.md b/releasenotes.md index 0eacde3ee..6679cb16e 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -22,6 +22,7 @@ - Deprecated use of `?` to create optional. - Vectors not converted to arrays when passed as raw vaargs. #2776 - Second value in switch range not checked properly, causing an error on non-const values. #2777 +- Broken cast from fault to array pointer #2778. ### Fixes - Regression with npot vector in struct triggering an assert #2219. diff --git a/src/compiler/sema_casts.c b/src/compiler/sema_casts.c index 99b1488a1..8c2e22a4d 100644 --- a/src/compiler/sema_casts.c +++ b/src/compiler/sema_casts.c @@ -2609,7 +2609,7 @@ CastFunction cast_function[CONV_LAST + 1][CONV_LAST + 1] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // CONST ENUM {XX2VO, 0, PT2BO, PT2IN, 0, 0, 0, EX2VC, 0, 0, 0, 0, 0, 0, 0, 0, 0, PT2PT, 0, 0, PT2PT, 0, 0, 0 }, // FUNC {XX2VO, 0, TI2BO, TI2IN, 0, TI2PT, 0, EX2VC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, TI2PT, TI2PT, 0, 0 }, // TYPEID - {XX2VO, 0, AF2BO, FA2IN, 0, FA2PT, 0, EX2VC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, FA2IN, FA2IN, 0, 0 }, // ANYFAULT + {XX2VO, 0, AF2BO, FA2IN, 0, FA2PT, 0, EX2VC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, FA2PT, FA2PT, 0, 0 }, // ANYFAULT {XX2VO, 0, PT2BO, PT2IN, 0, PT2PT, 0, EX2VC, 0, 0, 0, 0, 0, PT2AY, PT2AY, 0, 0, PT2PT, 0, 0, 0, PT2PT, 0, 0 }, // VOIDPTR {XX2VO, 0, PT2BO, PT2IN, 0, PT2PT, AP2SL, EX2VC, 0, 0, 0, 0, 0, PT2AY, PT2AY, 0, 0, 0, 0, 0, PT2PT, PT2PT, PT2FE, 0 }, // ARRAYPTR { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // INFERRED diff --git a/test/test_suite/bitstruct/fault_to_arrptr.c3 b/test/test_suite/bitstruct/fault_to_arrptr.c3 new file mode 100644 index 000000000..0700b252e --- /dev/null +++ b/test/test_suite/bitstruct/fault_to_arrptr.c3 @@ -0,0 +1,9 @@ +// #target: linux-x64 +import libc; +fn void a() +{ + fault x = f; // #error: 'f' could not be found + ulong z = (ulong); // #error: Implicitly casting 'typeid' to 'ulong' is not permitted + z = (Sigset_t*)(x); // #error: Implicitly casting 'Sigset_t*' (ulong[16]*) to 'ulong' +} +