[Issue 4722] New: Debug Phobos lib
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Aug 24 19:51:22 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4722
Summary: Debug Phobos lib
Product: D
Version: D2
Platform: All
OS/Version: Windows
Status: NEW
Severity: enhancement
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: bearophile_hugs at eml.cc
--- Comment #0 from bearophile_hugs at eml.cc 2010-08-24 19:51:16 PDT ---
This is one example from Phobos, a small part of std.bitmanip.BitArray:
void init(void[] v, size_t numbits)
in
{
assert(numbits <= v.length * 8);
assert((v.length & 3) == 0);
}
body
{
ptr = cast(uint*)v.ptr;
len = numbits;
}
But if you compile (with no compilation arguments but the file name) this wrong
program runs, with no runtime errors:
import std.bitmanip: BitArray;
void main() {
ubyte[4] data;
BitArray bits;
bits.init(data, 100);
}
The problem is real, but I don't know if the following suggestion is stupid or
impossible.
The idea is to have two precompiled libs, like phobos.lib and phobos_debug.lib
(where the debug one contains the asserts too), and DMD (or rmdm) may pick
phobos.lib if the -release switch is used, and use phobos_debug.lib otherwise.
This may allow to replace the enforce() in Phobos with normal asserts inside
DbC contracts.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list