September 25, 2023 [Issue 24159] New: BetterC: appending to dynamic arrays no longer errors at compile time | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24159 Issue ID: 24159 Summary: BetterC: appending to dynamic arrays no longer errors at compile time Product: D Version: D2 Hardware: All OS: All Status: NEW Keywords: betterC Severity: normal Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: dave287091@gmail.com The following program compiled with betterC used to error at compile time, now it only errors at runtime: extern(C) int main(){ int[] x = null; x ~= 3; // this should be diagnosed at compile time return x[0]; } You now get a runtime assertion like: Assertion failed: (Cannot append to array if compiling without support for runtime type information!), function core.internal.array.appending._d_arrayappendcTXImpl!(int[], int)._d_arrayappendcTX, file <snip>/import/core/internal/array/appending.d, line 52. Which is this file: https://github.com/dlang/dmd/blob/396fc8d477ca66e20f6b4fec4d532f2aee053ba3/druntime/src/core/internal/array/appending.d#L52 Getting an error at runtime is much worse than compile time as some code might be rarely exercised. Also note that the failed assertion doesn’t even point to your line of code where you used a feature banned in betterC! -- |
Copyright © 1999-2021 by the D Language Foundation