D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2514 - indexing error in struct.tupleof[i]
Summary: indexing error in struct.tupleof[i]
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2008-12-13 14:33 UTC by BCS
Modified: 2014-03-01 00:36 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description BCS 2008-12-13 14:33:54 UTC
template Foo(T, uint n = 0)
{
   static if(T.tupleof.length <= n) const char[] Foo = "";
   else const char[] Foo = typeof(T.tupleof[n]).stringof ~ " " ~ Foo!(T,n+1);
}

import std.stdio;
void main()
{
  writef("%d, %s\n", __VERSION__, Foo!(S)); /// generates "int, int, int"
}

struct S { int i; uint j; float k; }

for this, the following is a work around:

-   else const char[] Foo = typeof(T.tupleof[n]).stringof ~ " " ~ Foo!(T,n+1);
+   else const char[] Foo = typeof(T.tupleof)[n].stringof ~ " " ~ Foo!(T,n+1);
Comment 1 Don 2010-08-25 12:40:16 UTC
Fixed in 2.023 and 1.039