Change Log: 2.068.0
Download D 2.068.0
released Aug 09, 2015
Compiler Changes
- Warning: Change in helper function generation might cause link error.
- The new -profile=gc switch enables profiling memory allocation.
- unittest blocks no longer parsed unless -unittest is specified.
- Compiler generated inclusive destructor and postblit functions for UDTs are now accessible as .__xdtor and .__xpostblit, see dmd#4650.
Language Changes
Library Changes
- Many phobos functions were rangified.
- std.typetuple was renamed to std.meta but a backwards compatible forwarding module will remain.
- TypeTuple was renamed to AliasSeq but a backwards compatible alias will remain.
- hexString was added to replace core language hex strings.
- hasUDA was added to help check for the existence of user-defined attributes on symbols.
- GC API calls can now be profiled separately.
- The runtime implementations of synchronized and synchronized (obj) were rewritten to fix a race condition during mutex initialization, see druntime#1274.
- The handwritten object.di header was replaced by directly using the object.d source file, see druntime#1222 for more details.
- The AA implementation now uses open addressing.
- Merging code coverage reports was fixed, see Bugzilla 14464 and dmd_coverSetMerge.
- executeShell now ignores the SHELL environment variable and always uses sh, see Bugzilla 14282.
- byLine was improved to use getdelim where available and is now up to 3x faster, see Bugzilla 11810.
- The newly added ordered and strictlyOrdered can be used to test whether a few given values are ordered.
- RefCounted uses the new return attribute to enable escape checking for it's payload.
List of all bug fixes and enhancements in D 2.068.
Compiler Changes
- Warning: Change in helper function generation might cause link error.
In order to fix Issue 14828 compiler helper functions for array bounds checking and assert are now generated only once when a module is compiled, not everytime they are used. This may lead to link errors when using a module without compiling and linking against it.
If you encounter link errors like
undefined reference to '_D5mylib5mymod7__arrayZ'
undefined reference to '_D5mylib5mymod8__assertFiZv'
undefined reference to '_D5mylib5mymod15__unittest_failFiZv'
then you're not compiling and/or not linking the module mylib.mymod. - The new -profile=gc switch enables profiling memory allocation.
When compiling with -profile=gc dmd will instrument GC allocations to be traced by the runtime. The runtime accumulates the traces and writes a report to the file profilegc.log upon program termination.
Example:
bytes allocated, type, function, file:line 171 immutable(char)[] example.concat example.d:4 24 closure D main example.d:18 16 example.Klass D main example.d:20
Note: GC allocations using the core.memory interface are not profiled.
- unittest blocks no longer parsed unless -unittest is specified:
When the unittest code is not necessary, it will be merely analyzed as the tokens enclosed with paired braces, to speed up compilation.
unittest { auto r = test(); assert(r); } // If you don't specify -unittest, no AST generated for the unittest block. unittest { the contents is just ignored. } // Since 2.067: this had caused parsing error. // From 2.068: no error happens, because it's equivalent with: enum unittest_code = q{ the contents is just ignored. };
Language Changes
- pragma(inline) was added:
A new pragma was added for more fine-grained control of inlining. It must be used together with the -inline switch.
pragma(inline, true) // errors if function isn't inlined int double(int val) { return 2 * val; }
pragma(inline, false) // never inline int double(int val) { return 2 * val; }
Read the documentation for more details.
- Attributes for auto return function are now inferred.
Just like templated functions, functions with an auto return type must always have a function body. The compiler was changed to take advantage of this fact and now also infers attributes for them.
auto foo()() {} // template function auto bar() {} // non-template function without return type void baz() {} // non-template function with return type static assert(is(typeof(&foo!()) == void function() pure nothrow @nogc @safe)); static assert(is(typeof(&bar) == void function() pure nothrow @nogc @safe)); static assert(is(typeof(&baz) == void function()));
- Indexed type tuples can now be followed by dot identifiers.
A parsing limitation was lifted and it's now possible to use an indexed type tuple followed by dot identifiers as typename.
alias TypeTuple(T...) = T; struct S { alias T = int; alias U = TypeTuple!(long, string); } alias Pair = TypeTuple!(S, S); struct X(Types...) // used tuple parameter { Types[0].T a; // Types[0] == S, then typeof(a) == S.T == int Types[0].U[1] b; // Types[0].U == S.U, then typeof(b) == S.U[1] == string } alias x = X!Pair;
- Support template parameter deduction from function default arguments:
When performing IFTI templated types can now be deduced from a parameter's default argument. This avoids a redundant and error prone declaration of the default type.
void previously(T=int)(T t = 0) { } // it was necessary to also specify a default type void now(T)(T t = 0) { } // the default type can be deduced from the default argument as int void main() { previously(); now(); }
- Invalid reinterpret casts can be detected in the frontend.
Invalid reinterpret casts are now detected in the compiler frontend instead of the backend. This allows to check for possible reinterpret casts during compile time and improves the error messages for invalid casts.
pragma(msg, is(typeof({ void* x; auto y = cast(void delegate())x; }))); // Since 2.067: it prints 'true' // From 2.068: it prints 'false' void test() { void* x; auto y = cast(void delegate())x; } // Since 2.067: it had reported internal compiler error "Error: e2ir: cannot cast ..." // From 2.068: it reports proper frontend error.
Library Changes
- Many phobos functions were rangified.
Many phobos functions that allocated GC memory were changed to support ranges or were complemented by an alternative supporting ranges. Using ranges often eliminates GC allocations.
setExtension("foo.jpg", ".png"); // allocates a new string withExtension("foo.jpg", ".png"); // returns a range without allocating
- GC API calls can now be profiled separately.
The GC option --DRT-gcopt=profile has been enhanced to accept an additional level 2 that allows profiling API calls grouped by most common operations.
As this instrumentation has an impact on the GC performance even if unused, you have to recompile the GC module with -debug=PROFILE_API, e.g.
dmd test.d -O -inline -debug=PROFILE_API -Ipath-to-druntime/src path-to-druntime/src/gc/gc.d ./test --DRT-gcopt=profile:2
The profiling summary will then look like this:malloc: 9768628 calls, 531 ms realloc: 0 calls, 0 ms free: 0 calls, 0 ms extend: 1100 calls, 0 ms other: 826 calls, 0 ms lock time: 160 ms GC API: 692 ms GC summary: 12 MB, 52 GC 331 ms, Pauses 227 ms < 4 ms API 692 ms
The malloc function includes time for GC collections. Lock time (GC synchronization) is measured separately and not included in the other times.
- The AA implementation now uses open addressing.
The runtime implementation for associative arrays was rewritten and now uses open addressing with quadratic probing and triangular numbers. This is much more cache friendly than the old separate chaining implementation and can result in ~25% faster lookups for big AAs. Also see druntime#1229.
Note: As the allocation pattern changed (the table is bigger, nodes are smaller) you might see a small drop in performance because the GC manages big allocations less efficiently.
List of all bug fixes and enhancements in D 2.068:
DMD Compiler regressions
- Bugzilla 9279: [REG2.055/2.063] Static array return value implicitly converted to immutable dynamic array
- Bugzilla 12984: [REG2.068a] ICE on forward reference of derived class from other instantiated class
- Bugzilla 13816: [REG2.066.0] The compiler crashes with recursive tuple expansion
- Bugzilla 14207: [REG2.065] [CTFE] ICE on unsupported reinterpret cast in compile time
- Bugzilla 14351: [REG2.063] inout base class constructor can't be called
- Bugzilla 14390: [REG2.068a] ICE or bad "has forward references" error with circular class structure
- Bugzilla 14406: [REG2.068a] GIT HEAD ignores forward reference and generates wrong code
- Bugzilla 14430: [REG2.060] Null parameter is detected as non-null.
- Bugzilla 14468: [Reg 2.068.0-devel] overload mismatch for template instance with typesafe variadic parameter
- Bugzilla 14481: [REG2.066] ICE with forward reference of manifest constant on template arguments
- Bugzilla 14520: [REG2.067.0] string/alias template overload
- Bugzilla 14528: [REG2.058a] can't pass protected member to template by alias
- Bugzilla 14546: "ClockType.uptime is not supported by MonoTimeImpl on this system"
- Bugzilla 14549: isVirtualMethod does not work well with Github DMD
- Bugzilla 14552: [REG2.066] SIGSEGV with compile construction nested class in predicate
- Bugzilla 14556: [REG2.067] can't instantiate struct that has constructor and static array of enum
- Bugzilla 14560: [REG2.058] Strange -inline behavior
- Bugzilla 14568: [REG2.067] gaggederrors ICE
- Bugzilla 14571: [REG2.064] Large static arrays seem to lock up DMD
- Bugzilla 14572: cannot build dmd from source anymore: 'g++ -m64: No such file or directory'
- Bugzilla 14573: [REG2.067] Extreme memory usage when synchronized( object ) is used
- Bugzilla 14587: [REG2.064] generated 64 bit code for switch jump tables is wrong
- Bugzilla 14594: [REG2.068a] DDoc for template functions and structs has disappeared
- Bugzilla 14606: [REG2.067.0] Bad code with -inline and structs
- Bugzilla 14609: [REG2.068a] Github HEAD: DMD assertion failure for valid code
- Bugzilla 14610: [REG2.067] 'null this' assertion missing in 2.067
- Bugzilla 14634: dmd crashes without any input
- Bugzilla 14642: [REG2.066] ICE in ctfeInterpret
- Bugzilla 14666: [REG2.061] Bogus forward reference error
- Bugzilla 14672: [REG2.067.0] Internal error: e2ir.c 4620 when copying array of derived class to an array of base class
- Bugzilla 14805: [REG2.064] Unreasonably slow "new Struct[large]"
- Bugzilla 14806: [REG2.063] alias this doesn't force elaborate equality, but is followed during it
- Bugzilla 14814: ld: GOT load reloc does not point to a movq instruction
- Bugzilla 14828: [REG2.067] duplicate symbol __ModuleInfoZ depending on ordering of files passed to dmd
- Bugzilla 14829: [REG2.066.0] wrong code with -O -inline
- Bugzilla 14834: [REG 2.068-b2] dirEntries with mask stopped working with "-inline -debug"
- Bugzilla 14836: [REG2.068a] Multiple variadic template argument trick broken
- Bugzilla 14838: [REG 2.066] Wrong attribute inference for auto-generated class destructor with static array of non-POD type
- Bugzilla 14844: [REG2.068a] __traits(allMembers) must not visit yet not instantiated template members
- Bugzilla 14851: [REG2.068.0-b2] Cannot assign array operation result to static array variable
- Bugzilla 14853: [REG2.066] DMD segfaults with the cast from mutable struct new to shared
- Bugzilla 14890: [REG 2.068.0-rc1] Can not construct a RedBlackTree of Tuples
DMD Compiler bugs
- Bugzilla 1759: Closures and With Statements
- Bugzilla 2803: template + default argument = doesn't work
- Bugzilla 3869: Unreasonable error without line number: "recursive template expansion"
- Bugzilla 5770: Template constructor bypass access check
- Bugzilla 6613: Can't use empty tuple as default value for variadic template function parameter
- Bugzilla 6766: Forward reference error for default struct/class arguments
- Bugzilla 8217: static nested class can reference outer scope by template instantiation
- Bugzilla 8234: symbols used in CTFE affect the function literal type
- Bugzilla 9023: CTFE: cannot use ~= on an empty AA.
- Bugzilla 10158: 'offsetof' property of nested struct does not work properly
- Bugzilla 10282: Refused assignment of vector op result to const array
- Bugzilla 10492: Illegal Instruction for mixin template with scope declarations
- Bugzilla 10972: aggregate postblit doesn't clean up in case of failure
- Bugzilla 11166: Forward reference error when alias of template instance is private
- Bugzilla 12036: Wrong code with auto-returning function as mixin alias param
- Bugzilla 12152: Cannot forward reference subclass member in superclass
- Bugzilla 12406: Broken delegate closure
- Bugzilla 12603: [CTFE] goto does not correctly call dtors
- Bugzilla 12799: Forward reference to nested enum with struct.sizeof
- Bugzilla 12971: Missing REX prefix for 8 bit register access
- Bugzilla 13270: ddoc can't find parameters of ditto'd function overloads
- Bugzilla 13920: DMD crash when trying to set a delegate from __traits(getOverloads)
- Bugzilla 13985: Wrong code when using "super" to call final interface method
- Bugzilla 14097: root/async.c: use after free
- Bugzilla 14185: [ICE] [mtype.c] compiler segfault in in Type::aliasthisOf
- Bugzilla 14243: mixin template scope inconsistency?
- Bugzilla 14249: Loose error check for incorrect template mixin
- Bugzilla 14264: Destructor not called when struct is returned from a parenthesis-less function call
- Bugzilla 14268: Win64: debug info for associative arrays have no type information
- Bugzilla 14281: duplicate .debug_info entries for arrays, delegates and aa's
- Bugzilla 14290: is-expression accepts instantiation of already instantiated template
- Bugzilla 14320: Improve diagnostic message for "undefined identifier" error
- Bugzilla 14321: Unnecessary destructor call with and AA's
- Bugzilla 14325: [CTFE] Comparison of AAs makes wrong result
- Bugzilla 14330: Wrong DWARF type of dynamic array variable
- Bugzilla 14343: Postfix increment doesn't work on structs with immutable member
- Bugzilla 14348: typeof(x).ident is not accepted as a symbol
- Bugzilla 14352: Two goto cases in one case branch does not work correctly
- Bugzilla 14357: Match on specType does not check the conflict with already deduced template arguments
- Bugzilla 14371: [CTFE] Binary assignment expression makes wrong result in compile-time
- Bugzilla 14388: ICE with idup-ed struct literal in template argument
- Bugzilla 14398: Segfault when nested struct in static array accesses context
- Bugzilla 14407: No protection and attributes check for class/struct allocator in NewExp
- Bugzilla 14409: false positive "Error: one path skips constructor"
- Bugzilla 14416: .sizeof yields 1 for uninstantiated struct templates
- Bugzilla 14425: Indirect template instantiation within is expression causes missing linker symbols
- Bugzilla 14446: ICE on invalid import
- Bugzilla 14510: Bad tail call optimization with static arrays
- Bugzilla 14596: Error: e2ir: cannot cast malloc(42u) of type void* to type char[]
- Bugzilla 14617: PTHREAD_MUTEX_INITIALIZER does not work on OSX
- Bugzilla 14629: Type system breaking and wrong code bugs in casting reference types to typeof(null)
- Bugzilla 14649: ICE on invalid array operation with string literals
- Bugzilla 14656: "auto" of "auto ref" spills over to other function
DMD Compiler enhancements
- Bugzilla 9914: Do attribute inference for auto functions
- Bugzilla 11003: Improve .di generation
- Bugzilla 14465: CTFE exception stacktrace shows location of Exception constructor
- Bugzilla 14547: Ddoc should prefer new Variable Template syntax
Phobos regressions
- Bugzilla 14712: GIT HEAD : std.net.curl regressions
- Bugzilla 14748: Removing std.stdio import causes 2x increase in "Hello, world" program binary filesize
- Bugzilla 14765: [Reg2.068.0] Rangified functions no longer accept types that implicitly cast to string
- Bugzilla 14842: [REG 2.068-b2] approxEqual does not work with integers
- Bugzilla 14881: [REG] posix.mak omits package.d files when building zip file
Phobos bugs
- Bugzilla 12702: [FixIncluded] std.container.RedBlackTree's in operator is not const
- Bugzilla 13534: std.variant can violate memory safety
- Bugzilla 14282: executeShell should use sh and ignore the SHELL env variable
- Bugzilla 14373: std.range.refRange doesn't work on mere input ranges
- Bugzilla 14408: std.process: Can't start interactive process from Windows GUI application
- Bugzilla 14422: std.process: Pipes do not append to files on Win64
- Bugzilla 14469: file.readText on Win64 doesn't work for files > 4GB.
- Bugzilla 14526: GetOptException DDOC needs cleanup
- Bugzilla 14544: isForwardRange failed to recognise valid forward range
- Bugzilla 14575: compile error with std.range.refRange when front/back isn't implicitly convertible from const to mutable
- Bugzilla 14585: destructor called on garbage in std.variant
Phobos enhancements
- Bugzilla 14194: nothrow emplace for classes needed
- Bugzilla 14288: std.windows.registry should use std.windows.syserror
- Bugzilla 14289: WindowsException should not attempt to parse code 0
- Bugzilla 14368: stdio.rawRead underperforms stdio
- Bugzilla 14432: move construction for RefCounted
- Bugzilla 14457: Algebraic does not allow assignment from subset type
- Bugzilla 14535: std.net.curl.CurlException should include status line
- Bugzilla 14548: std.stdio.File should have sync() method (fsync/FlushFileBuffers wrapper)
- Bugzilla 14586: can't get an immutable value from a const std.variant.Variant
Druntime regressions
- Bugzilla 14626: [REG2.066] byValue doesn't work with inout AA
- Bugzilla 14746: [REG2.068a] Behavior change with struct destructor and alias this
- Bugzilla 14863: CLOCK_BOOTTIME should be optional to support <2.6.39 kernels
Druntime bugs
- Bugzilla 6607: critical_.d and critical.c use double check locking the wrong way
- Bugzilla 12289: incorrect core.stdc.stdio.fpos_t alias
- Bugzilla 14350: Unit test failures are not displayed in Windows GUI programs
- Bugzilla 14401: typeid(shared X).init is empty for class types
- Bugzilla 14423: struct destructors not finalized for AA values
- Bugzilla 14464: coverage merge doesn't work
- Bugzilla 14476: core.thread unit tests failing on FreeBSD 9+
- Bugzilla 14511: Profiler does not work with multithreaded programs
- Bugzilla 14565: dmd -profile produces garbled output for long-running CPU-intensive processes
Druntime enhancements
- Bugzilla 12891: add atomicFetchAdd and atomicFetchSub to core.atomic
- Bugzilla 14385: AA should use open addressing hash
dlang.org bugs
- Bugzilla 12803: __traits(getFunctionAttributes) is not documented
- Bugzilla 13527: ddoc website documentation does not match the current built-in symbols
- Bugzilla 14079: Variable templates' documentation not generated.
- Bugzilla 14080: No mention of documented unittests on ddoc's page
- Bugzilla 14326: syntax highlighting of dpl-docs no longer works
- Bugzilla 14418: D-style Variadic Function example does not compile
Tools bugs
- Bugzilla 13758: RDMD renames directory if -ofNAME is the name of a directory
- Bugzilla 14259: rdmd: --build-only / -of / -od incompatible with --dry-run
Installer bugs
- Bugzilla 14801: OS X installer not compatible with OS X 10.11
- Bugzilla 14864: windows uninstall during installation pops up spurious warning