Created attachment 15 [details] the code that segfaults 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
The D class reference ("slicer" in your code) is null and all methods in D are virtual (except private/final ones) - trying to call them with a null ref will fail - there's no compiler bug here.
Thanks for clarification. Nice to hear that it isn't a compiler bug.