betterC and std.containers don't work together?

Ki Rill rill.ki at yahoo.com
Tue Sep 19 04:02:00 UTC 2023


I've been trying out std containers. Checked Phobos code - all 
seems to be @nogc. Good. Then I try out this and it fails because 
something throws in array construction and that's not available 
in betterC: https://run.dlang.io/is/WAjVuG

```D
extern(C):
import core.stdc.stdio;
import std.container;

void main()
{
     printf("hello, world\n");
     Array!int ai;
     ai ~= 1;
}

/* Compiler output:
/dlang/dmd/linux/bin64/../../src/druntime/import/core/internal/array/construction.d(207): Error: cannot use try-catch statements with -betterC
/dlang/dmd/linux/bin64/../../src/phobos/std/container/array.d(151): Error: template instance `core.internal.array.construction._d_arraysetctor!(const(Array!int)[], const(Array!int))` error instantiating
/dlang/dmd/linux/bin64/../../src/phobos/std/container/array.d(244):        instantiated from here: `RangeT!(const(Array!int))`
/dlang/dmd/linux/bin64/../../src/phobos/std/container/array.d(633):        instantiated from here: `RangeT!(Array!int)`
onlineapp.d(8):        instantiated from here: `Array!int`
/dlang/dmd/linux/bin64/../../src/druntime/import/core/internal/array/construction.d(207): Error: cannot use try-catch statements with -betterC
/dlang/dmd/linux/bin64/../../src/phobos/std/container/array.d(151): Error: template instance `core.internal.array.construction._d_arraysetctor!(immutable(Array!int)[], immutable(Array!int))` error instantiating
/dlang/dmd/linux/bin64/../../src/phobos/std/container/array.d(639):        instantiated from here: `RangeT!(immutable(Array!int))`
onlineapp.d(8):        instantiated from here: `Array!int`
*/
```



More information about the Digitalmars-d mailing list