www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Ooh - Got me an OPTLINK error!

reply "Janice Caron" <caron800 googlemail.com> writes:
The following won't compile with the latest D2.007. The error is:

OPTLINK (R) for Win32  Release 7.50B1
Copyright (C) Digital Mars 1989 - 2001  All Rigths Reserved

demo.obj(demo)  Offset 0035EH Record Type 009D
 Error 16: Index Range

It seems to be the alias on the last line that kills it.

///////////////////////////

void main() {}

template A()
{
    const uint N = 16;

    class A
    {
        ubyte[] f()
        {
            return new ubyte[N];
        }
    }
}

alias A!() B;
Nov 10 2007
next sibling parent "Steven Schveighoffer" <schveiguy yahoo.com> writes:
"Janice Caron"  wrote
 The following won't compile with the latest D2.007. The error is:

 OPTLINK (R) for Win32  Release 7.50B1
 Copyright (C) Digital Mars 1989 - 2001  All Rigths Reserved

 demo.obj(demo)  Offset 0035EH Record Type 009D
 Error 16: Index Range

 It seems to be the alias on the last line that kills it.

 ///////////////////////////

 void main() {}

 template A()
 {
    const uint N = 16;

    class A
    {
        ubyte[] f()
        {
            return new ubyte[N];
        }
    }
 }

 alias A!() B;

This doesn't seem valid. I thought you could only use implicit template properties if there was only one member of the template? Does changing the line to A!().A B; work? From spec: If a template has exactly one member in it, and the name of that member is the same as the template name, that member is assumed to be referred to in a template instantiation: template Foo(T) { T Foo; // declare variable Foo of type T } void test() { Foo!(int) = 6; // instead of Foo!(int).Foo } -Steve
Nov 10 2007
prev sibling parent "Janice Caron" <caron800 googlemail.com> writes:
On 11/10/07, Steven Schveighoffer <schveiguy yahoo.com> wrote:
 Does changing the line to A!().A B; work?

Nope. Exact same error.
 From spec:
 If a template has exactly one member in it <snip>

Well gosh. Until now, I've always found it works just fine even if the template has multiple members in it. But I'll watch out for that in the future.
Nov 10 2007