Change Log: 2.107.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
Compiler changes
- Catch clause must take only const or mutable exceptions
- Improvements for the C++ header generation
- A function with enum storage class is now deprecated, not an error
- Add -nothrow Switch to Compiler
- Added support for Intel CET (Control-flow Enforcement Technology) IBT (Indirect Branch Tracking) protection
- Creating a scope class instance with a non-scope constructor is @system only with DIP1000
- Global const variables can no longer be initialized from a non-shared static constructor
- Global variables can now be initialized with Associative Arrays
- _d_newarray{U,T,iT} are converted to templates
Runtime changes
Library changes
List of all upcoming bug fixes and enhancements in D 2.107.0.
Compiler changes
- 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 }
- 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.
- A function with enum storage class is now deprecated, not an error
The error was introduced in 2.105.0.
- 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.
- 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
- 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.
- 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 }
- 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.
- _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
- 4 core.memory.GC functions have been marked @safe
- GC.enable
- GC.disable
- GC.collect
- GC.minimize
Library changes
- 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.
- 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.
- 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
- Bugzilla 22212: dmd version has -dirty suffix on windows
- Bugzilla 24179: Ddoc broke D code sections
- Bugzilla 24266: ImportC: struct initializer entry gets ignored
- Bugzilla 24274: [REG master] ImportC: unrecognized C initializer with array in struct
- Bugzilla 24295: [betterC] ICE with new int[]
- Bugzilla 24301: [REG 2.100] Misleading error message when passing non-copyable struct by value in @safe code
- Bugzilla 24338: Cannot concatenate dynamic arrays of enum type with static array base type
DMD Compiler bug fixes
- Bugzilla 16357: cast(T[])[x] casts x to T instead of [x] to T[]
- Bugzilla 20339: isPOD returns true if sizeof is accessed inside struct declaration
- Bugzilla 20369: shadowed variable in foreach loop always considered "foreach variable"
- Bugzilla 22216: Incomplete/incorrect error message for mutability overloads
- Bugzilla 22483: DMD generates invalid string sections that work by coincidence
- Bugzilla 22905: gdb backtrace contains wrong location
- Bugzilla 23411: ImportC: undefined identifier __builtin_nanf
- Bugzilla 23713: compilable/testcstuff1.c:206:1: error: static assertion failed: sizeof(u'a') == 4
- Bugzilla 23714: compilable/testcstuff1.c:213:1: error: static assertion failed: u'ab' == 0x610062
- Bugzilla 23818: Error HMODULE not defined, please use HMODULE
- Bugzilla 23972: class identity check is broken
- Bugzilla 24031: ImportC: rejects nested C initializers
- Bugzilla 24094: importC __declspec not working in front of declaration statement
- Bugzilla 24200: ImportC: .di file collected macro conflicts with Special Token
- Bugzilla 24224: __traits(initSymbol) treats aggregate-derived enum as base type
- Bugzilla 24248: const constructor call with mutable target gives wrong error message
- Bugzilla 24252: ci: Error: error writing file 'compilable\testcstuff3_0.obj'
- Bugzilla 24264: ImportC: inliner trips on _Bool return
- Bugzilla 24276: ImportC: typedef aliases not emitted correctly in .di files
- Bugzilla 24280: ImportC: forward reference error when compiling multiple files
- Bugzilla 24281: Segfault with missing field after named argument
- Bugzilla 24283: [SIMD][CODEGEN] Bad codegen with and not + AVX2 registers
- Bugzilla 24292: Struct with destructor wrongly returned in register
- Bugzilla 24293: ImportC: C preprocessor output should use temporary files
- Bugzilla 24303: anonymous struct problems when typedef'd in separate C files
- Bugzilla 24304: __uint16_t, __uint32_t, __uint64_t are not recognized
- Bugzilla 24306: ImportC: same name structs in separate C files interfere when compiled together
- Bugzilla 24309: Memory allocation failed on Azure pipeline
- Bugzilla 24311: Named enum with AA base type causes ICE
- Bugzilla 24319: OpenBSD: Use correct type for file_time
- Bugzilla 24326: ImportC: segfault on nameless enum translation with -H
- Bugzilla 24340: Invalid export directives generated
DMD Compiler enhancements
- Bugzilla 14387: Disallow string literals as assert conditions
- Bugzilla 18919: __FILE__ and __LINE__ should work when used in default argument expressions
- Bugzilla 23629: importC: Need to support code coverage analysis
- Bugzilla 24069: ImportC does not parse function pointer as parameter without name
- Bugzilla 24125: ImportC: vector type initializer not understood
- Bugzilla 24155: ImportC: accept C23 default initializers
- Bugzilla 24206: Can't alias a function type that returns a type with a TypeSuffix
- Bugzilla 24238: Confusing "not an lvalue"error messages
- Bugzilla 24247: Improve constructor not callable using $modifier object error
- Bugzilla 24294: ImportC: unrecognized command line option -Wno-builtin-macro-redefined with gcc
- Bugzilla 24297: ImportC incompatible with glibc _FORTIFY_SOURCE
- Bugzilla 24316: Allow CTFE access to immutable variable through pointer
Phobos regression fixes
- Bugzilla 24243: Can't format chain(filter, filter)
Phobos bug fixes
- Bugzilla 24151: std.container.array: Array!string("") does not compile
- Bugzilla 24215: std.traits.isBasicType!Enum should be false
- Bugzilla 24278: std.math.abs promotes unsigned argument to 32 bits
- Bugzilla 24339: std.mmfile has poor documentation
- Bugzilla 24342: T[][].until(T[]) breaks if sentinel is longer than 1.
- Bugzilla 24348: Inaccurate documentation for hasSlicing with infinite range
Phobos enhancements
- Bugzilla 11111: std.algorithm.canFind should support Needles...
- Bugzilla 24075: Can't use toChars with ushort or ubyte
- Bugzilla 24318: Nullable should support non-copyable objects
Druntime bug fixes
- Bugzilla 4071: Missing support to share memory and objects between DLLs and executable
- Bugzilla 24272: operations.arrayOp is forced @nogc nothrow pure
- Bugzilla 24298: cpp_delete should check for null
- Bugzilla 24349: object noreturn link is missing
Druntime enhancements
- Bugzilla 19702: Remove usage of DECLARE_HANDLE
- Bugzilla 20332: associative array clear function should be @safe
dlang.org bug fixes
- Bugzilla 23712: ImportC: Unclear documentation of what type is inferred from integer literals (type of 9223372036854775808 is undefined)
- Bugzilla 24239: dlang.org tests on CircleCI run out of memory
- Bugzilla 24241: Spec disallows missing default arguments
dlang.org enhancements
- Bugzilla 24176: Parameters of opApply delegate don't have to be ref
- Bugzilla 24177: Array literal can implicitly convert to an expected type
- Bugzilla 24210: Function types are not documented
- Bugzilla 24313: Download page should reference Github nightlies
- 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.
- Adam D. Ruppe
- Atila Neves
- Basile Burg
- Brian Callahan
- Daniel Pflager
- Danil Sidoruk
- Denis Feklushkin
- Dennis
- Dennis Korpel
- Feldwor
- HuskyNator
- Iain Buclaw
- IchorDev
- Imperatorn
- imrying
- Jeremy
- jibal
- Johan Engelen
- Johannes
- Mai-Lapyst
- Martin Kinkelin
- Mathias Lang
- Mathis Beer
- Max Haughton
- mhh
- Mike Parker
- Nicholas Wilson
- Nick Treleaven
- Ogi-kun
- Paul Backus
- Petar Kirov
- Puneet Goel
- Rainer Schuetze
- Razvan Nitu
- richard (rikki) andrew cattermole
- Richard (Rikki) Andrew Cattermole
- richard (rikki) andrew cattermole
- ryuukk
- Siarhei Siamashka
- Sönke Ludwig
- Teodor Dutu
- Tim Schendekehl
- Timon Gehr
- vabenil
- Vladimir Panteleev
- Walter Bright
- Yang Yujie
- Семён Марьясин