www.digitalmars.com         C & C++   DMDScript  

D.gnu - [Issue 25] New: Segmentation fault on a simple template class; no

http://gdcproject.org/bugzilla/show_bug.cgi?id=25


           Summary: Segmentation fault on a simple template class; no
                    segfault if substitute class by structure
    Classification: Unclassified
           Product: GDC
           Version: 4.7.x
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: Normal
         Component: gdc
        AssignedTo: ibuclaw gdcproject.org
        ReportedBy: alexander.samoilov gmail.com


Created attachment 15
  --> http://gdcproject.org/bugzilla/attachment.cgi?id=15
the same code as in the issue's body

Dear Developers,

The following simple code produces segfault with both gdc 4.7 and latest dmd:
---------------------------------------------------------------------------
/*struct*/ class bits(int MSB, int LSB) {

    enum { msb  = MSB, lsb  = LSB, span = MSB-LSB+1, }

    static const ulong mask = (1L << span) - 1;

    ulong slice(ulong val) const { return ((val >> lsb) & mask); }
}

import std.stdio;
void main() {

    ulong a = 0xFEE0DDF00D;
    bits!(28,12) slicer;

    auto sliced = slicer.slice(a);
    writefln("slicer(28,12) : %X",slicer.slice(a));
}
---------------------------------------------------------------------------
There will not be segfault if substitute 'class' by 'struct' or declare
method bits::slice as static
(as 'static ulong slice(ulong val) { return ((val >> lsb) & mask);' } ).

Thanks,
Alexander

-- 
Configure issuemail: http://gdcproject.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all issue changes.
Nov 03 2012