D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4722 - Debug Phobos lib
Summary: Debug Phobos lib
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All Windows
: P4 enhancement
Assignee: No Owner
URL:
Keywords: bootcamp
Depends on:
Blocks:
 
Reported: 2010-08-24 19:51 UTC by bearophile_hugs
Modified: 2024-12-13 17:53 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2010-08-24 19:51:16 UTC
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.
Comment 1 dlangBugzillaToGithub 2024-12-13 17:53:08 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/18295

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB