www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12458] New: No out of bounds assert errors in not-release mode for std.bitmanip.BitArray

reply d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12458

           Summary: No out of bounds assert errors in not-release mode for
                    std.bitmanip.BitArray
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc


--- Comment #0 from bearophile_hugs eml.cc 2014-03-24 15:58:27 PDT ---
(This is tagged as error instead of enhancement request.)

This wrong code surprisingly compiles and runs with no errors:


void main() {
    import std.bitmanip: BitArray;
    BitArray ba;
    ba.length = 10;
    auto b = ba[100];
}


Built-in D arrays have bound tests, so in not-release mode I'd like BitArray to
give a run-time assert error on code like that. It helps me debug code that
uses BitArrays.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 24 2014
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12458


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2014-03-25
13:39:42 CET ---
This is strange, because I can see this is checked in the in blocks:

-----
    bool opIndex(size_t i) const
    in
    {
        assert(i < len);
    }
    body
    {
        // Andrei: review for    64-bit   
        return cast(bool) bt(ptr, i);
    }

    /**********************************************
     * Sets the $(D i)'th bit in the $(D BitArray).
     */
    bool opIndexAssign(bool b, size_t i)
    in
    {
        assert(i < len);
    }
    body
    {
        if (b)
            bts(ptr, i);
        else
            btr(ptr, i);
        return b;
    }
-----

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 25 2014
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12458



--- Comment #2 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2014-03-25
13:47:10 CET ---
(In reply to comment #1)
 This is strange, because I can see this is checked in the in blocks:

Oh I see what's going on, Phobos is built with -release mode. It seems to me that we should distribute both a -debug and -release mode version of the Phobos static library, and then allow the user to link with either one. I guess sc.ini can be manipulated in some way to enable this.. no idea. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 25 2014