Change Log: 2.096.0
Download D 2.096.0
released Mar 11, 2021
Compiler changes
- D ABI change on x86_64 Posix targets
- Added __c_complex_float, __c_complex_double, and __c_complex_real types
- Having both a copy constructor and a generated postblit is now deprecated
- DMD's JSON output will now always include the protection level
- DMD's JSON output now have distinct types for [shared] module constructor/destructor
- Deprecate local templates that receive local symbols by alias
- Improvements for the C++ header generation
- Add -gdwarf=<version> switch for the DMD compiler.
- Introduced __traits(getVisibility, Sym) as an alias to getProtection
- Plain synchronized statements now use run-time allocated mutexes.
- Allow shortened function implementations for single-expression functions.
Runtime changes
Library changes
List of all bug fixes and enhancements in D 2.096.0.
Compiler changes
- D ABI change on x86_64 Posix targets
The compiler has been updated to return the real part of creal numbers in ST0, and the imaginary part in ST1, to match the x86_64 System V ABI.
This is an ABI breaking change and requires recompiling libraries that make use of the creal type.
- Added __c_complex_float, __c_complex_double, and __c_complex_real types
This allows code interfacing with C and C++ to maintain ABI compatibility with _Complex types. It replaces the built-in types cfloat, cdouble, and creal which are due to be deprecated.
- Having both a copy constructor and a generated postblit is now deprecated
Up until this release, the postblit had priority over the copy constructor, no matter if the former was user-defined or generated. This prevented new code that uses the copy constructor to interact with library code that uses the postblit. To enable this interaction, having a generated postblit and a copy constructor (user-defined or generated) is now deprecated. For example:
// library code using postblit struct A { this(this) {} } // new code using copy constructor struct B { A a; this(const scope ref B) {} }
Up until this release, in the above code, struct B had a generated postblit that had priority over the user defined copy constructor. With this release, a deprecation will be issued at the definition of structB, stating that the postblit is going to be preferred to the copy constructor. If B has both a user-defined postblit and a copy constructor (generated or user-defined), the postblit will continue to have priority.
To get rid of the deprecation, the user can either:
- Explicitly @disable this(this) in struct B. That will instruct
- Define a postblit for struct B. That will instruct the compiler
- Remove all copy constructors from struct B. In this case the postblit
- DMD's JSON output will now always include the protection level
In previous release, the JSON output the compiler generates did not include the protection level if it was public. It is now always included.
- DMD's JSON output now have distinct types for [shared] module constructor/destructor
Previously, module constructors and destructors (shared or not) would be output as functions, and the only way for documentation generators to recognize them was to search for the pattern that was used for their naming. This means that external tools would need to depend on internal compiler details for generating documentation. From this release, 4 new values have been introduced for kind: shared static constructor, shared static destructor, static constructor, static destructor.
- Deprecate local templates that receive local symbols by alias
Support for instantiating local and member templates with local symbols was implemented in DMD 2.087.0. However, the implementation was incompatible with GDC and LDC backends.
In order to maintain feature parity among D implementations, this improvement has been deprecated, and may be removed from a future DMD release.
- Improvements for the C++ header generation
The following features/bugfixes/improvements were implemented for the experimental C++ header generator:
- Generate fieldwise constructors for aggregates
- Don't emit instantiated classes as unique class declarations
- Emit template arguments for instantiated base classes
- Don't emit enums for opaque types specially handled by the compiler
Note: The header generator is still considerer experimental, so please submit any bugs encountered to the bug tracker.
- Add -gdwarf=<version> switch for the DMD compiler.
Emit DWARF symbolic debug info (non-Windows machines only). Supported versions are 3, 4, and 5.
Once added, the -g switch is implicitly activated.
Note: DWARF Version 5 is experimental.
- Introduced __traits(getVisibility, Sym) as an alias to getProtection
Since the changes in v2.071.0, attributes such as private, protected, public, etc... are visibility attributes, and not protection attributes. However, the name of this trait predates such change and was thus inconsistent with all the other documentation. This change only introduce the new name, and getProtection has been left un-deprecated, and while using the new name is reccommended for users that only supports the latest version of the language, there is no plan to deprecate it.
- Plain synchronized statements now use run-time allocated mutexes.
Synchronized statements have two forms, synchronized and synchronized(exp). When there is no expression argument, a global mutex is created using a static buffer big enough to store the platform dependant critical section type and a pointer field.
Example:
void main() { synchronized { // __gshared byte[40 + 8] __critsec; // _d_criticalenter(&__critsec[0]); // scope(exit) _d_criticalexit(&__critsec[0]); (cast() counter) += 1; } }
This implementation suffers from a couple deficiencies. Neither the size nor alignment of the critsec buffer are obtained from the OS critical section type defined in druntime. As a result, if the size allocated by the compiler is too small, or the platform has strict alignment requirements, then the program run-time will crash on entering the synchronized statement.
This code will now call a new implementation that allocates the critical section lazily at run-time, moving all logic out of the compiler to druntime.
- Allow shortened function implementations for single-expresssion functions.
-preview=shortenedMethods is added. This allows functions to be written in a similar form to lambda functions:
// these 2 are equivalent int foo() { return 1; } int foo() => 1;
The syntax allows the form => expr to replace the function body { return expr; }
Runtime changes
- The druntime option callStructDtorsDuringGC has been removed
It had been deprecated in 2.088.
- FreeBSD declarations from statvfs that belong in mount have been removed
It had been deprecated in 2.082 in favor of core.sys.freebsd.sys.mount.
- Experimental llvm-libunwind based backtrace printing was added
Currently, druntime uses the backtrace and backtrace_symbols functions to provide debug informations (addresses and function names, respectively).
This can create issues for target that do not provide backtrace, such as Musl libc. Additionally, the backtrace interface is inherently limited, as it only allow to get up to X frames (where X is the size of the buffer), and forces them to be stored continuously in memory. The same apply to backtrace_symbols.
On the other hand, libunwind is an industry standard for unwinding and stack trace inspection. It has been ported to a variety of platform, has a simple yet flexible API, and is part of GCC, and a similar library is part of LLVM.
Starting from this release, druntime includes a way to use LLVM's libunwind as a backtrace provider. The support is limited to LLVM's version of libunwind, as it is available on Alpine Linux, and easier to interface with.
For packagers, one can define DRuntime_Use_Libunwind when building druntime, enabling the support by default.
Library changes
- Deprecate std.math : approxEqual
The template approxEqual for comparing floating point numbers has been deprecated.
Please use the template isClose instead, which has better default values and is symmetric in its arguments.
To (almost) keep the current behaviour of approxEqual(a, b) use isClose(a, b, 1e-2, 1e-2), but we recommend to adjust the code to make it work with isClose(a, b).
Dub changes
- More 'linker dflags' with DMD
-betterC, -L… and -Xcc=… dflags are now used for linking too.
- copyFiles can now be used in VisualD projects.
Files that are needed for the application to run can be specified in the copyFiles build option, which causes these files to be copied to the target path. The dub generator for VisualD now replicates this behaviour, so that this kind of applications can be successfully debugged in Visual Studio.
List of all bug fixes and enhancements in D 2.096.0:
DMD Compiler regression fixes
- Bugzilla 20661: opEquals not recognized for AA key (take two)
- Bugzilla 21319: DMD crashes on immutable circular reference
- Bugzilla 21547: Order of constructor declaration affects struct initializer
- Bugzilla 21678: "_d_arraysetlengthT is not callable using argument types" on chained array length assignment
- Bugzilla 21696: DMD 2.095.1 Compilation Crash
DMD Compiler bug fixes
- Bugzilla 5713: Broken final switch on ints
- Bugzilla 10619: Wrong local variable passed as alias arguments to templates
- Bugzilla 11717: CTFE: non-constant value with array and vector ops.
- Bugzilla 13667: ICE: stack overflow using self-referencing cast inside recursive alias this method
- Bugzilla 14831: Each function local symbols should have unique mangled name
- Bugzilla 15225: cannot overload directly aliased function literals
- Bugzilla 16635: Alias this for implicit conversion to "ref const(typeof(this))" causes dmd to segfault
- Bugzilla 17105: [ICE] SIMD Internal error with optimizations: backend\cod3.c 6807
- Bugzilla 18867: backend/cgcod.c crash on assignment to vector element
- Bugzilla 19788: compiler crash on slicing a enum typed as vector
- Bugzilla 20041: CTFE incorrect result with __vector
- Bugzilla 20111: asm VCVTPS2PH is not encoded correctly
- Bugzilla 20235: C++ ABI doesn't destruct struct arguments in the callee
- Bugzilla 20565: Local template declarations in different scopes produce uncaught name collisions
- Bugzilla 20695: Copy constructor disable default struct constructor
- Bugzilla 20821: Aliased template method confuses overload resolution
- Bugzilla 20868: DIP1000: scope delegate triggers error in unsafe code and it shouldn't
- Bugzilla 21214: simd: wrong diagnostic with unsupported vectors
- Bugzilla 21352: enum members should not be given UDAs of its parent enum declaration
- Bugzilla 21469: ICE core.simd when implementing _mm_set1_epi16
- Bugzilla 21471: Backend assertion triggered with -checkation=context and -inline
- Bugzilla 21472: -checkaction=context doesn't work with tupleof
- Bugzilla 21474: ICE with core.simd and -O (Illegal Instruction)
- Bugzilla 21481: functions in overloaded template are lost when the template overloads an alias
- Bugzilla 21489: Duplicated template instantiation using mixin inside alias declaration
- Bugzilla 21490: Optimizer can add SSE integer multiply for machines less than SSE4.1 which do not have it
- Bugzilla 21501: [REG 2.089.1] undefined identifier in package when using mixin and cyclic imports
- Bugzilla 21508: private class p in file p.d visible outside the file (module)
- Bugzilla 21515: extern(C) and extern(C++) returns creal in wrong order
- Bugzilla 21518: delegates not checked for attribute match in const arrays
- Bugzilla 21522: function gets lost when aliasing an overloaded function template
- Bugzilla 21526: x87 not rounding to precision on assignment on some platforms
- Bugzilla 21530: dtoh: Identifiers need to be sanitized wrt. reserved C++ keywords
- Bugzilla 21534: dtoh: Default params for default ctor missing template args
- Bugzilla 21543: dmd infinite loop on alias this and std.typecons.Nullable
- Bugzilla 21553: incorrect call to expressionSemantic() in statementsem.d
- Bugzilla 21598: checkaction=context reruns pure functions with debug blocks on failure
- Bugzilla 21640: @live not working with templates
- Bugzilla 21647: pragma(msg) should be able to print a void type
- Bugzilla 21659: [OSX] core.stdc.config.__c_ulonglong is forward referenced while looking for sizeof
- Bugzilla 21662: Extern linkage variables cannot be of types with disabled default construction
- Bugzilla 21668: Cannot declare ref parameter of opaque type
- Bugzilla 21682: checkaction=context fails for expressions using static operator overloads
DMD Compiler enhancements
- Bugzilla 7176: Lambda => syntax for function and methods too
- Bugzilla 10445: add .min, .max, etc. properties for vector types
- Bugzilla 19632: [SIMD] Error: invalid foreach aggregate
- Bugzilla 20788: Difference between colored and non colored output
- Bugzilla 21527: Unnecessary store to memory in SIMD code
- Bugzilla 21593: Only update file time if file to be written already exists
Phobos regression fixes
- Bugzilla 21663: std.concurrency.receiveOnly doesn't work with tuples
Phobos bug fixes
- Bugzilla 13663: Comparison of Tuples with floating point fields
- Bugzilla 15136: If we want toStringz to be fully correct, it needs to stop checking for '\0'
- Bugzilla 17269: formattedWrite of struct with Nullable string fails
- Bugzilla 20508: std.math.pow(-infinity, y) does not return NaN for imaginary or complex results
- Bugzilla 20539: std.conv.to: internal overload conflict for enums with base types that have a catch-all opEquals overload (?)
- Bugzilla 20848: Bug in formatValueImpl
- Bugzilla 21103: isDynamicArray instantiates unecessary templates
- Bugzilla 21444: bad string concat in static assert message
- Bugzilla 21555: std.container.array: insertBack is wrong and should be tested for Array!bool
- Bugzilla 21556: std.container.array: insertAfter is wrong and should be tested
- Bugzilla 21609: LinearCongruentialEngine fails for m = 0
- Bugzilla 21634: std.bitmanip: bitfields may generate invalid variable
- Bugzilla 21635: std.bitmanip: bitfields should produce better error messages with wrong parameters
- Bugzilla 21636: std.bitmanip: bitfields size of bitfield should be checked against size of used type
Phobos enhancements
- Bugzilla 21523: Microsoft Windows std.stdio.File.lock(), tryLock(), unlock(): do not allocate memory for error messages when they are not needed
- Bugzilla 21559: Speed up walkLength for narrow strings
- Bugzilla 21629: std.csv report one record on empty input
- Bugzilla 21638: std.typecons.RefCounted!(T, RefCountedAutoInitialize.no) should still work when T.this() is annotated with @disable
Druntime regression fixes
- Bugzilla 21309: Missing core.thread.threadbase documentation
- Bugzilla 21642: [REG 2.084] hashOf will fail to compile for some structs/unions that recursively contain shared enums
Druntime bug fixes
- Bugzilla 8046: simd.d needs some documentation
- Bugzilla 21544: -checkaction=context formats enum members as their base type
- Bugzilla 21666: wrong printf format specifier for real with -checkaction=context on Win64
Druntime enhancements
- Bugzilla 14790: coverage merge should detect changed source code
dlang.org bug fixes
- Bugzilla 21292: Chrome by default now blocks downloading .dmg or .exe files via HTTP
- Bugzilla 21493: Documentation broken hyperlink std.stdio
Contributors to this release (54)
A huge thanks goes to all the awesome people who made this release possible.
- Adam D. Ruppe
- aG0aep6G
- Andrei Alexandrescu
- Atila Neves
- Bartosz Wójcik
- Basile Burg
- Bastiaan Veelo
- Ben Jones
- Bernhard Seckinger
- berni42
- berni44
- Boris Carvajal
- brianush1
- Cameron Ross
- Crom (Thibaut CHARLES)
- Denis Feklushkin
- dkorpel
- Eugen Wissner
- Florian
- H. S. Teoh
- Hiroki Noda
- Iain Buclaw
- Jacob Carlborg
- Lucien Perregaux
- Luhrel
- Luís Ferreira
- Martin Kinkelin
- Martin Nowak
- Mathias Lang
- Mathis Beer
- mhh
- Mihaela Chirea
- Mike Parker
- MoonlightSentinel
- Nathan Sashihara
- Nicholas Wilson
- nordlow
- Paul Backus
- Petar Kirov
- Quirin F. Schroll
- Razvan Nitu
- rkulhanek
- Robert burner Schadek
- Roman Kashitsyn
- Roy Margalit
- Sebastian Wilzbach
- Stefan Koch
- Steven Schveighoffer
- Tim Schendekehl
- Tomáš Chaloupka
- Vladimir Panteleev
- Walter Bright
- Witold Baryluk
- سليمان السهمي (Suleyman Sahmi)