[Issue 884] New: Segfault in recursive template

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jan 24 15:08:04 PST 2007


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

           Summary: Segfault in recursive template
           Product: D
           Version: 1.001
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: fvbommel at wxs.nl


The following code segfaults DMD v1.001 (Linux, don't know about Windows)
-----
template Inner(Ts...) {

    const Inner = .Inner!((Ts));
}



auto x = Inner!();
-----

Just so you people don't think I'm crazy for trying to compile that ;), let me
just state for the record that above code is *way* cut down from much more
complicated code. I removed everything I could while retaining the segfault.

Above code is probably invalid. The original code may or may not have been
valid, I'm not sure.

The original code also segfaulted on v1.00, and perhaps earlier (not sure when
I started working on it).

Some notes I made while cutting it down:
* The Ts in the initializer was originally sliced with [1..$], with the same
result (if filled with some value parameters). Only in 'static if (Ts.length >
0)', of course.
* The initializer expression in general used to be a bit more complicated :p.
* Braces around Ts were initially added to avoid "tuple Ts is used as a type",
later avoided "tuple is not a valid template value argument" and currently need
to be retained to eliminate "circular reference to 'Inner'", which is pretty
obvious in the current code :). Since the code that produced those errors
didn't segfault DMD, they stayed in.
* The Inner member originally had type T[] (T being the template parameter of
an enclosing template), but the compiler segfaulted with void[] as well.


-- 



More information about the Digitalmars-d-bugs mailing list