www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12477] New: std.bitmanip should emit informative diagnostics

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

           Summary: std.bitmanip should emit informative diagnostics
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: andrej.mitrovich gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2014-03-26
23:50:07 CET ---
-----
import std.bitmanip;

struct S
{
    mixin(bitfields!(
        uint, "a", 6,
        uint, "b", 10));
}

void main()
{
    S s;
    s.a = uint.max;
}
-----

$ dmd -g -run test.d

-----
core.exception.AssertError test.d-mixin-7(8): Assertion failure
----------------
0x0040240B in _d_assert
0x0040217D in _Dmain at C:\dev\code\d_code\test.d(15)
0x00402704 in D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv
0x004026D7 in void rt.dmain2._d_run_main(int, char**, extern (C) int
function(char[][])*).runAll()
0x004025F0 in _d_run_main
0x00402198 in main
0x004189DD in mainCRTStartup
0x75803677 in BaseThreadInitThunk
0x778A9D72 in __RtlUserThreadStart
0x778A9D45 in _RtlUserThreadStart
-----

The number is out of range for the bitfield size, but the diagnostic doesn't
say that.

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


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc


--- Comment #1 from bearophile_hugs eml.cc 2014-03-26 16:32:46 PDT ---
It's not easy to work on the implementation of std.bitmanip.bitfields. The code
is not simple.

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


safety0ff.bugz <safety0ff.bugz gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |safety0ff.bugz gmail.com


--- Comment #2 from safety0ff.bugz <safety0ff.bugz gmail.com> 2014-03-26
21:52:23 PDT ---
(In reply to comment #1)
 It's not easy to work on the implementation of std.bitmanip.bitfields. The code
 is not simple.

It's not that bad, https://github.com/D-Programming-Language/phobos/blob/master/std/bitmanip.d#L116 just need to have error messages added to them. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 26 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12477



--- Comment #3 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2014-03-27
12:12:59 CET ---
(In reply to comment #2)
 (In reply to comment #1)
 It's not easy to work on the implementation of std.bitmanip.bitfields. The code
 is not simple.

It's not that bad, https://github.com/D-Programming-Language/phobos/blob/master/std/bitmanip.d#L116 just need to have error messages added to them.

I don't know when that code was written, but maybe we can replace it with templates nowadays instead of using string mixins. It would make things much more readable (and probably faster to compile). -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 27 2014
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12477



--- Comment #4 from safety0ff.bugz <safety0ff.bugz gmail.com> 2014-03-27
04:31:49 PDT ---
(In reply to comment #3)
 I don't know when that code was written, but maybe we can replace it with
 templates nowadays instead of using string mixins. It would make things much
 more readable (and probably faster to compile).

I think re-writing bitfield is pretty low bang for buck (unless somebody already has a mental skeleton/sketch of an implementation.) -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 27 2014