Thread overview
[Issue 8474] New: bitfields doesn't work with bitfield over 31 bits
Jul 30, 2012
Andrej Mitrovic
[Issue 8474] bitfields doesn't work with 32 bit fields
Aug 01, 2012
Era Scarecrow
Oct 05, 2013
David Nadlinger
July 30, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8474

           Summary: bitfields doesn't work with bitfield over 31 bits
           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> 2012-07-30 11:01:59 PDT ---
import std.bitmanip;
struct Foo
{
    mixin(bitfields!(
        uint, "bits1", 32,
    ));
}

void main() { }

std\bitmanip.d(76): Error: shift by 32 is outside the range 0..31

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 31, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8474


monarchdodra@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monarchdodra@gmail.com


--- Comment #1 from monarchdodra@gmail.com 2012-07-31 04:40:13 PDT ---
FYI: Bitfileds DO work with fields over 32. They just don't work for fields that are EXACTLY 32.

The problem is that since the field is 32 bits long, it is placed in a uint. When trying to create the "signed mask" though the "1" is attempted to be placed at index 32 (1 << 32), which becomes illegal.

The problem does not appear if the field is SMALLER than 32, since the mask
will fit.
The problem does not appear if the field is BIGGER than 32, the type will be
placed in a ulong.

Oh yeah, and fields that are exactly 64 bits long don't work either. This is arguably less of a problem though... but still wrong.

=>Changing title

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 31, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8474



--- Comment #2 from monarchdodra@gmail.com 2012-07-31 09:49:40 PDT ---
More details: The problem only appears if the 32 (64) bit field is aligned with
0.

THIS will not create a bug:

--------
import std.bitmanip;
struct A
{
    mixin(bitfields!(
        uint, "a",  1,
        uint, "b", 32,
        uint, "c", 31,)
    );
}
void main()
{
  A a;
};

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 01, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8474


Era Scarecrow <rtcvb32@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |rtcvb32@yahoo.com
         AssignedTo|nobody@puremagic.com        |rtcvb32@yahoo.com


--- Comment #3 from Era Scarecrow <rtcvb32@yahoo.com> 2012-08-01 08:01:49 PDT ---
My current branch resolves this issue. Once the pull is accepted this will be resolved.

https://github.com/rtcvb32/phobos/commit/620ba57cc0a860245a2bf03f7b7f5d6a1bb58312

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 05, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=8474


David Nadlinger <code@klickverbot.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
                 CC|                            |code@klickverbot.at
         Resolution|                            |FIXED


--- Comment #4 from David Nadlinger <code@klickverbot.at> 2013-10-05 08:18:20 PDT ---
https://github.com/D-Programming-Language/phobos/pull/1613

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------