January 26, 2006 _arguments in constructor | ||||
|---|---|---|---|---|
| ||||
Repost from D.bugs, as Dave confirmed that it does not affect dmd 0.144 on win nor linux. So I guess it goes as a more GDC specific bug.
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
| ||||
February 24, 2006 Re: _arguments in constructor | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Fredrik Olsson Attachments: | Fredrik Olsson schrieb am 2006-01-26: > Repost from D.bugs, as Dave confirmed that it does not affect dmd 0.144 on win nor linux. So I guess it goes as a more GDC specific bug. > > 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. Added to DStress as http://dstress.kuehne.cn/run/v/variadic_argument_12_A.d http://dstress.kuehne.cn/run/v/variadic_argument_12_B.d http://dstress.kuehne.cn/run/v/variadic_argument_12_C.d Thomas | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply