Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

Change Log: 2.107.0

previous version: 2.106.0

Download D nightlies
To be released


This changelog has been automatically generated from all commits in master since the last release.

  • The full-text messages are assembled from the changelog/ directories of the respective repositories: dmd, druntime, phobos, tools, dlang.org, installer, and dub.
  • See the DLang-Bot documentation for details on referencing Bugzilla. The DAutoTest PR preview doesn't include the Bugzilla changelog.
  • The pending changelog can be generated locally by setting up dlang.org and running the pending_changelog target:
    make -f posix.mak pending_changelog


2.107.0 comes with 13 major changes and 75 fixed Bugzilla issues. A huge thanks goes to the 48 contributors who made 2.107.0 possible.

List of all upcoming bug fixes and enhancements in D 2.107.0.

Compiler changes

  1. Catch clause must take only const or mutable exceptions

    In 2.104, throwing qualified types was deprecated.

    It is also unsafe to catch an exception as immutable, inout or shared. This is because the exception may still be accessible through another mutable or non-shared reference. Catching an exception with those qualifiers is now deprecated.

    auto e = new Exception("first");
    try {
            throw e;
    } catch(immutable Exception ie) { // now an error
            e.msg = "second";
            assert(ie.msg == "first"); // would fail
    }
    
  2. Improvements for the C++ header generation

    The following features/bugfixes/improvements were implemented for the experimental C++ header generator:

    • Static variables used in a default argument context are now emitted using their fully qualified name.

    Note: The header generator is still considered experimental, so please submit any bugs encountered to the bug tracker.

  3. A function with enum storage class is now deprecated, not an error

    The error was introduced in 2.105.0.

  4. Add -nothrow Switch to Compiler

    dmd itself (and presumably others) do not throw Exceptions, preferring other methods for dealing with errors. There is a cost, however, in supporting Exceptions even when they are never thrown. The cost is in adding stack unwinders for things like RAII objects, and preventing numerous optimizations across try-catch boundaries.

    Adding nothrow to all the code in a project turns out to be an inordinate amount of work if the program is large. Putting nothrow: at the top of the module doesn't influence the status for member functions in a class or struct, the nothrow: will have to be repeated for each class/struct.

    Adding the -nothrow switch to the compiler causes the stack unwinders to not be added and enables the optimizations. This capability is already there for -betterC code, this would just enable it for regular D code.

    The switch does not affect semantic analysis, just the code generation. Name mangling is not affected.

    The switch is useful for determining what effect exception handling has on an executable's size and performance in non-throwing code.

  5. Added support for Intel CET (Control-flow Enforcement Technology) IBT (Indirect Branch Tracking) protection

    CET is a technology that is useful for preventing an attacker from redirecting a program's control flow, specifically IBT prevents an attacker from causing an indirect branch to go to an unintended place.

    Intel IBT expects the compiler to emit special instructions (endbr32 and endbr64) which in older processors that do not support IBT are equivalent to nop instructions, consequently a program compiled with active IBT will be compatible on any x86 processor and the protection will be opportunistically active on supported processors.

    To enable Intel IBT protection in DMD you need to pass the -fIBT flag to the compiler, consequently the compiler will manage the emission of instructions for IBT by itself. Be careful when using inline assembly, the compiler will not automatically handle IBT inside an inline assembly.

    To find out within a D program whether IBT has been activated or not use the traits getTargetInfo as follows:

    // IBT active
    static assert(__traits(getTargetInfo, "CET") == 1);  // CET == 1 if IBT is active
    
    // IBT not active
    static assert(__traits(getTargetInfo, "CET") == 0);  // CET == 0 if IBT is not active
    
  6. Creating a scope class instance with a non-scope constructor is @system only with DIP1000

    The fix for issue 23145 broke existing code, so it's put behind -preview=DIP1000 now, just like other scope related errors.

  7. Global const variables can no longer be initialized from a non-shared static constructor

    Just like immutable data, global const data is not placed in Thread Local Storage (TLS), so initializing it in a thread-local static constructor allows you to violate const: see issue 24056 for details. Doing this will now result in a deprecation:

    int x;
    const int y;
    immutable int z;
    
    static this()
    {
        x = 1;
        y = 2; // Deprecation: cannot modify const variable
        z = 3; // Error: cannot modify immutable variable (same as before)
    }
    

    As a corrective action, move the initialization to a shared static constructor:

    const int y;
    
    shared static this()
    {
        y = 4; // OK
    }
    
  8. Global variables can now be initialized with Associative Arrays

    Formerly, module constructors or enum had to be used to initialize global variables with Associtive Arrays. By internally lowering to Steven Schveighoffer's newaa struct implementation, Associative Arrays can now be used directly.

    immutable string[string] table = ["key": "value"];
    
    void main()
    {
        assert(table["key"] == "value");
    }
    

    When the key/value types have toHash, opEquals or ~this defined, they must be callable at compile time. An if (!__ctfe) branch can be used to make a destructor only run at run time. Future enhancements may obviate the need for this workaround.

  9. _d_newarray{U,T,iT} are converted to templates

    The template _d_newarrayT now uses DBI to check what type of initialiser is required by the type of the elements in the array. Thus it replaces both _d_newarrayT and _d_newarrayiT.

    _d_newarrayU is the generic implementation of both of the above hooks and just allocates the array. It hasn't been incorporated into _d_newarrayT because it is used by dup. Currently dup is still using the non-template _d_newarrayU. A future PR will update dup to use the new template.

    Now the compiler performs the following lowering:

    S[] s = new S[10]
    
    // is now lowered to:
    S[] s = _d_newarrayT!S(10);
    

    This change adds the new templates to core.internal.array.construction. In addition, it implements template __arrayClearPad, __arrayAlloc, __arrayStart and __setArrayAllocLength in core.internal.array.utils. __arrayClearPad and __arrayStart were also removed from rt.lifetime. The others can't be removed yet because they receive a TypeInfo argument and are called by other hooks in rt.lifetime.

Runtime changes

  1. 4 core.memory.GC functions have been marked @safe

    • GC.enable
    • GC.disable
    • GC.collect
    • GC.minimize

Library changes

  1. Undo etc.c.odbc deprecation and enable usage on non-Windows systems

    Previously, the etc.c.odbc bindings were deprecated and forwarded the core.sys.windows versions of the bindings via public import. However, ODBC is supported on all major platforms and the machine translated MinGW bindings in core.sys.windows have version(Windows) specified which results in being unable to use those bindings on non-Windows platforms. The bindings have been returned to etc.c.odbc, undeprecated, and support for non-Windows platforms enabled.

  2. isInputRange now takes an optional element type.

    isInputRange now has an optional 2nd template parameter that defaults to void. If not void, it only evaluates to true if the range's element type is the same type as this extra argument, modulo const. For instance, isInputRange!(int[], const(int)) is true, but isInputRange!(int[], string) is false.

  3. Add Unshared to std.traits.

    Unshared is the shared equivalent of Unconst. It strips off the outer layer of shared from a type. e.g.

        static assert(Unshared!(shared int) == int);
        static assert(Unshared!(shared(int[])) == shared(int)[]);
    

    So, Unconst strips off the outer layer of const, immutable, and inout; Unshared strips off the outer layer of shared; and Unqual strips off all qualifiers from the outer layer of a type.


List of all bug fixes and enhancements in D 2.107.0:

DMD Compiler regression fixes

  1. Bugzilla 22212: dmd version has -dirty suffix on windows
  2. Bugzilla 24179: Ddoc broke D code sections
  3. Bugzilla 24266: ImportC: struct initializer entry gets ignored
  4. Bugzilla 24274: [REG master] ImportC: unrecognized C initializer with array in struct
  5. Bugzilla 24295: [betterC] ICE with new int[]
  6. Bugzilla 24301: [REG 2.100] Misleading error message when passing non-copyable struct by value in @safe code
  7. Bugzilla 24338: Cannot concatenate dynamic arrays of enum type with static array base type

DMD Compiler bug fixes

  1. Bugzilla 16357: cast(T[])[x] casts x to T instead of [x] to T[]
  2. Bugzilla 20339: isPOD returns true if sizeof is accessed inside struct declaration
  3. Bugzilla 20369: shadowed variable in foreach loop always considered "foreach variable"
  4. Bugzilla 22216: Incomplete/incorrect error message for mutability overloads
  5. Bugzilla 22483: DMD generates invalid string sections that work by coincidence
  6. Bugzilla 22905: gdb backtrace contains wrong location
  7. Bugzilla 23411: ImportC: undefined identifier __builtin_nanf
  8. Bugzilla 23713: compilable/testcstuff1.c:206:1: error: static assertion failed: sizeof(u'a') == 4
  9. Bugzilla 23714: compilable/testcstuff1.c:213:1: error: static assertion failed: u'ab' == 0x610062
  10. Bugzilla 23818: Error HMODULE not defined, please use HMODULE
  11. Bugzilla 23972: class identity check is broken
  12. Bugzilla 24031: ImportC: rejects nested C initializers
  13. Bugzilla 24094: importC __declspec not working in front of declaration statement
  14. Bugzilla 24200: ImportC: .di file collected macro conflicts with Special Token
  15. Bugzilla 24224: __traits(initSymbol) treats aggregate-derived enum as base type
  16. Bugzilla 24248: const constructor call with mutable target gives wrong error message
  17. Bugzilla 24252: ci: Error: error writing file 'compilable\testcstuff3_0.obj'
  18. Bugzilla 24264: ImportC: inliner trips on _Bool return
  19. Bugzilla 24276: ImportC: typedef aliases not emitted correctly in .di files
  20. Bugzilla 24280: ImportC: forward reference error when compiling multiple files
  21. Bugzilla 24281: Segfault with missing field after named argument
  22. Bugzilla 24283: [SIMD][CODEGEN] Bad codegen with and not + AVX2 registers
  23. Bugzilla 24292: Struct with destructor wrongly returned in register
  24. Bugzilla 24293: ImportC: C preprocessor output should use temporary files
  25. Bugzilla 24303: anonymous struct problems when typedef'd in separate C files
  26. Bugzilla 24304: __uint16_t, __uint32_t, __uint64_t are not recognized
  27. Bugzilla 24306: ImportC: same name structs in separate C files interfere when compiled together
  28. Bugzilla 24309: Memory allocation failed on Azure pipeline
  29. Bugzilla 24311: Named enum with AA base type causes ICE
  30. Bugzilla 24319: OpenBSD: Use correct type for file_time
  31. Bugzilla 24326: ImportC: segfault on nameless enum translation with -H
  32. Bugzilla 24340: Invalid export directives generated

DMD Compiler enhancements

  1. Bugzilla 14387: Disallow string literals as assert conditions
  2. Bugzilla 18919: __FILE__ and __LINE__ should work when used in default argument expressions
  3. Bugzilla 23629: importC: Need to support code coverage analysis
  4. Bugzilla 24069: ImportC does not parse function pointer as parameter without name
  5. Bugzilla 24125: ImportC: vector type initializer not understood
  6. Bugzilla 24155: ImportC: accept C23 default initializers
  7. Bugzilla 24206: Can't alias a function type that returns a type with a TypeSuffix
  8. Bugzilla 24238: Confusing "not an lvalue"error messages
  9. Bugzilla 24247: Improve constructor not callable using $modifier object error
  10. Bugzilla 24294: ImportC: unrecognized command line option -Wno-builtin-macro-redefined with gcc
  11. Bugzilla 24297: ImportC incompatible with glibc _FORTIFY_SOURCE
  12. Bugzilla 24316: Allow CTFE access to immutable variable through pointer

Phobos regression fixes

  1. Bugzilla 24243: Can't format chain(filter, filter)

Phobos bug fixes

  1. Bugzilla 24151: std.container.array: Array!string("") does not compile
  2. Bugzilla 24215: std.traits.isBasicType!Enum should be false
  3. Bugzilla 24278: std.math.abs promotes unsigned argument to 32 bits
  4. Bugzilla 24339: std.mmfile has poor documentation
  5. Bugzilla 24342: T[][].until(T[]) breaks if sentinel is longer than 1.
  6. Bugzilla 24348: Inaccurate documentation for hasSlicing with infinite range

Phobos enhancements

  1. Bugzilla 11111: std.algorithm.canFind should support Needles...
  2. Bugzilla 24075: Can't use toChars with ushort or ubyte
  3. Bugzilla 24318: Nullable should support non-copyable objects

Druntime bug fixes

  1. Bugzilla 4071: Missing support to share memory and objects between DLLs and executable
  2. Bugzilla 24272: operations.arrayOp is forced @nogc nothrow pure
  3. Bugzilla 24298: cpp_delete should check for null
  4. Bugzilla 24349: object noreturn link is missing

Druntime enhancements

  1. Bugzilla 19702: Remove usage of DECLARE_HANDLE
  2. Bugzilla 20332: associative array clear function should be @safe

dlang.org bug fixes

  1. Bugzilla 23712: ImportC: Unclear documentation of what type is inferred from integer literals (type of 9223372036854775808 is undefined)
  2. Bugzilla 24239: dlang.org tests on CircleCI run out of memory
  3. Bugzilla 24241: Spec disallows missing default arguments

dlang.org enhancements

  1. Bugzilla 24176: Parameters of opApply delegate don't have to be ref
  2. Bugzilla 24177: Array literal can implicitly convert to an expected type
  3. Bugzilla 24210: Function types are not documented
  4. Bugzilla 24313: Download page should reference Github nightlies
  5. Bugzilla 24331: @nogc and GC.disable() are often confused

Contributors to this release (48)

A huge thanks goes to all the awesome people who made this release possible.

previous version: 2.106.0