www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - _arguments in constructor

reply Fredrik Olsson <peylow gmail.com> writes:
This example should not assert I believe:

===
module main;

class Foo {
   uint args;
   this(...) {
     args = _arguments.length;
     foreach(TypeInfo typeInfo; _arguments) {
       typeInfo.print();
     }
   }
}

int main(char[][] args) {
   auto foo = new Foo(1, 2, 3);
   assert(foo.args == 3);
   return 0;
}
===

I compile with GDC 0.17, om Mac OS X 10.4.4.

The output is:
TypeInfo[]
int
int
int

So it seams that the hidden variable _arguments is included in itself 
for constructors.

// Fredrik Olsson
Jan 25 2006
parent reply Dave <Dave_member pathlink.com> writes:
Works fine (doesn't assert) w/ dmd v0.144 on either/both WinXP and Linux.

In article <dr8js8$2g3j$1 digitaldaemon.com>, Fredrik Olsson says...
This example should not assert I believe:

===
module main;

class Foo {
   uint args;
   this(...) {
     args = _arguments.length;
     foreach(TypeInfo typeInfo; _arguments) {
       typeInfo.print();
     }
   }
}

int main(char[][] args) {
   auto foo = new Foo(1, 2, 3);
   assert(foo.args == 3);
   return 0;
}
===

I compile with GDC 0.17, om Mac OS X 10.4.4.

The output is:
TypeInfo[]
int
int
int

So it seams that the hidden variable _arguments is included in itself 
for constructors.

// Fredrik Olsson
Jan 25 2006
parent Fredrik Olsson <peylow treyst.se> writes:
Dave skrev:
 Works fine (doesn't assert) w/ dmd v0.144 on either/both WinXP and Linux.
 
So then it is a GDC specific (or perhaps even OS X specific) bug, I better repost it in D.gnu for safe measure. // Fredrik Olsson
 In article <dr8js8$2g3j$1 digitaldaemon.com>, Fredrik Olsson says...
 This example should not assert I believe:

 ===
 module main;

 class Foo {
   uint args;
   this(...) {
     args = _arguments.length;
     foreach(TypeInfo typeInfo; _arguments) {
       typeInfo.print();
     }
   }
 }

 int main(char[][] args) {
   auto foo = new Foo(1, 2, 3);
   assert(foo.args == 3);
   return 0;
 }
 ===

 I compile with GDC 0.17, om Mac OS X 10.4.4.

 The output is:
 TypeInfo[]
 int
 int
 int

 So it seams that the hidden variable _arguments is included in itself 
 for constructors.

 // Fredrik Olsson
Jan 26 2006