Bug 10817 – Linker error with postcondition contract in a release library

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-08-13T07:14:00Z
Last change time
2015-06-09T05:10:39Z
Keywords
contracts, industry, link-failure
Assigned to
nobody
Creator
david.eckardt

Comments

Comment #0 by david.eckardt — 2013-08-13T07:14:27Z
**** // Module in a library, compiled with -release module a; class A { int f ( ) out (x) {assert(x);} body {return 1;} } **** // User code, compiled without -release module b; import a; class B: A { override int f ( ) {return super.f();} } int main ( ) { return (new B).f(); } **** $ dmd -lib -release a.d $ dmd b.d -La.a b.o: In function `_D1b1B1fMFZi': b.d:(.text._D1b1B1fMFZi+0x60): undefined reference to `_D1a1A1fMFZi8__ensureMFKiZv' Apparently B.f() references the postcondition of A.f(), which it overrides, but that is omitted because A is compiled with -release. This is very unfortunate as it can make it impossible to use a library that is compiled with -release.
Comment #1 by david.eckardt — 2013-08-13T07:18:50Z
The industry in this case is sociomantic.com.
Comment #2 by public — 2014-04-24T13:08:56Z
After internal discussion closing this as invalid. DMD can't possibly know if external module A comes from is compiled in release or debug mode and thus can't guess if symbol can be legally referenced. We fix that problem for our project by providing both debug and release build of a library and using matching one to link with.