[Issue 8655] New: bitfields and Typedef don't mix

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Sep 13 20:33:27 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8655

           Summary: bitfields and Typedef don't mix
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: andrej.mitrovich at gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2012-09-13 20:33:42 PDT ---
import std.typecons;
import std.bitmanip;
static import core.stdc.config;

alias Typedef!(core.stdc.config.c_ulong) c_ulong;

struct Foo
{
    mixin(bitfields!(
        c_ulong, "NameOffset", 31,
        c_ulong, "NameIsString", 1
    ));
}

void main()
{ }

It's great to see we've deprecated typedef for a library solution that doesn't
work.

:\DMD\dmd2\windows\bin\..\..\src\phobos\std\bitmanip.d(77): Error: Cannot
interpret Typedef!(uint,0u) at compile time
D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\bitmanip.d(77): Error: expression
(Typedef!(uint,0u)).opDispatch() < 0u is not constant or does not evaluate to a
bool
D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\bitmanip.d(111): Error: Cannot
interpret Typedef!(uint,0u) at compile time
D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\bitmanip.d(159): Error: template
instance
std.bitmanip.createAccessors!("_NameOffset_NameIsString",Typedef!(uint,0u),"NameOffset",31,0u)
error instantiating
D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\bitmanip.d(213):       
instantiated from here:
createFields!("_NameOffset_NameIsString",0,Typedef!(uint,0u),"NameOffset",31,Typedef!(uint,0u),"NameIsString",1)
test.d(11):        instantiated from here:
bitfields!(Typedef!(uint,0u),"NameOffset",31,Typedef!(uint,0u),"NameIsString",1)
D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\bitmanip.d(77): Error: Cannot
interpret Typedef!(uint,0u) at compile time
D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\bitmanip.d(77): Error: expression
(Typedef!(uint,0u)).opDispatch() < 0u is not constant or does not evaluate to a
bool
D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\bitmanip.d(111): Error: Cannot
interpret Typedef!(uint,0u) at compile time
D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\bitmanip.d(159): Error: template
instance
std.bitmanip.createAccessors!("_NameOffset_NameIsString",Typedef!(uint,0u),"NameIsString",1,31u)
error instantiating
D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\bitmanip.d(160):       
instantiated from here:
createFields!("_NameOffset_NameIsString",31u,Typedef!(uint,0u),"NameIsString",1)
D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\bitmanip.d(213):       
instantiated from here:
createFields!("_NameOffset_NameIsString",0,Typedef!(uint,0u),"NameOffset",31,Typedef!(uint,0u),"NameIsString",1)
test.d(11):        instantiated from here:
bitfields!(Typedef!(uint,0u),"NameOffset",31,Typedef!(uint,0u),"NameIsString",1)
D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\bitmanip.d(160): Error: template
instance
std.bitmanip.createFields!("_NameOffset_NameIsString",31u,Typedef!(uint,0u),"NameIsString",1)
error instantiating
D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\bitmanip.d(213):       
instantiated from here:
createFields!("_NameOffset_NameIsString",0,Typedef!(uint,0u),"NameOffset",31,Typedef!(uint,0u),"NameIsString",1)
test.d(11):        instantiated from here:
bitfields!(Typedef!(uint,0u),"NameOffset",31,Typedef!(uint,0u),"NameIsString",1)
D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\bitmanip.d(213): Error: template
instance
std.bitmanip.createFields!("_NameOffset_NameIsString",0,Typedef!(uint,0u),"NameOffset",31,Typedef!(uint,0u),"NameIsString",1)
error instantiating
test.d(11):        instantiated from here:
bitfields!(Typedef!(uint,0u),"NameOffset",31,Typedef!(uint,0u),"NameIsString",1)
test.d(11): Error: template instance
std.bitmanip.bitfields!(Typedef!(uint,0u),"NameOffset",31,Typedef!(uint,0u),"NameIsString",1)
error instantiating

-- 
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