digitalmars.D.bugs - DMD 0.132: Bizarre template interaction with aliases and dependent
- Burton Radons (21/21) Sep 25 2005 This code fails compilation with the error message "f.d(10): this for
- Regan Heath (32/53) Sep 25 2005 I tried it with 0.133 on Windows...
- Burton Radons (2/47) Sep 26 2005 Confirmed fixed on Linux in 0.133.
- Burton Radons (16/43) Sep 26 2005 Whoops, scratch that. The problem is NOT fixed in 0.133 (I tested a
- =?ISO-8859-1?Q?Thomas_K=FChne?= (20/40) Sep 26 2005 -----BEGIN PGP SIGNED MESSAGE-----
This code fails compilation with the error message "f.d(10): this for
data needs to be type B not type B *". It's valid code and should work.
struct A (uint D)
{
alias B! (D - 1) b;
}
struct B (uint D)
{
uint [D] data;
uint foo () { return data [0]; }
}
alias B! (3) b3;
alias B! (4) b4;
The error goes away if the "alias B! (3) b3;" line is removed, the
"alias B! (D - 1) b;" line is removed or changed to "alias B! (3) b;",
or the "uint foo () { return data [0]; }" line is changed to "uint foo
() { return this.data [0]; }".
Another variant that works is to change the "alias B! (3) b3;" line to
"alias B! (4) b4;" and to change the "alias B! (D - 1) b;" line to
"alias B! (D) b;". So it seems to be an interaction between constant
folding and aliasing.
Sep 25 2005
On Sun, 25 Sep 2005 12:49:23 -0700, Burton Radons
<burton-radons smocky.com> wrote:
This code fails compilation with the error message "f.d(10): this for
data needs to be type B not type B *". It's valid code and should work.
struct A (uint D)
{
alias B! (D - 1) b;
}
struct B (uint D)
{
uint [D] data;
uint foo () { return data [0]; }
}
alias B! (3) b3;
alias B! (4) b4;
The error goes away if the "alias B! (3) b3;" line is removed, the
"alias B! (D - 1) b;" line is removed or changed to "alias B! (3) b;",
or the "uint foo () { return data [0]; }" line is changed to "uint foo
() { return this.data [0]; }".
Another variant that works is to change the "alias B! (3) b3;" line to
"alias B! (4) b4;" and to change the "alias B! (D - 1) b;" line to
"alias B! (D) b;". So it seems to be an interaction between constant
folding and aliasing.
I tried it with 0.133 on Windows...
C:\Library\D\src\temp>dmd
Digital Mars D Compiler v0.133
Copyright (c) 1999-2005 by Digital Mars written by Walter Bright
..
C:\Library\D\src\temp>dmd bug8.d
C:\Library\D\dmd\bin\..\..\dm\bin\link.exe bug8,,,user32+kernel32/noi;
<compiles fine>
When run my version outputs 0 twice (expected), full source below.
[bug8.d]
import std.stdio;
struct A (uint D)
{
alias B! (D - 1) b;
}
struct B (uint D)
{
uint [D] data;
uint foo () { return data [0]; }
}
alias B! (3) b3;
alias B! (4) b4;
void main()
{
b3 a;
b4 b;
writefln(a.foo());
writefln(b.foo());
}
Regan
Sep 25 2005
Regan Heath wrote:On Sun, 25 Sep 2005 12:49:23 -0700, Burton Radons <burton-radons smocky.com> wrote:Confirmed fixed on Linux in 0.133.This code fails compilation with the error message "f.d(10): this for data needs to be type B not type B *". It's valid code and should work. struct A (uint D) { alias B! (D - 1) b; } struct B (uint D) { uint [D] data; uint foo () { return data [0]; } } alias B! (3) b3; alias B! (4) b4; The error goes away if the "alias B! (3) b3;" line is removed, the "alias B! (D - 1) b;" line is removed or changed to "alias B! (3) b;", or the "uint foo () { return data [0]; }" line is changed to "uint foo () { return this.data [0]; }". Another variant that works is to change the "alias B! (3) b3;" line to "alias B! (4) b4;" and to change the "alias B! (D - 1) b;" line to "alias B! (D) b;". So it seems to be an interaction between constant folding and aliasing.I tried it with 0.133 on Windows... C:\Library\D\src\temp>dmd Digital Mars D Compiler v0.133 Copyright (c) 1999-2005 by Digital Mars written by Walter Bright .. C:\Library\D\src\temp>dmd bug8.d C:\Library\D\dmd\bin\..\..\dm\bin\link.exe bug8,,,user32+kernel32/noi; <compiles fine> When run my version outputs 0 twice (expected), full source below.
Sep 26 2005
Burton Radons wrote:
This code fails compilation with the error message "f.d(10): this for
data needs to be type B not type B *". It's valid code and should work.
struct A (uint D)
{
alias B! (D - 1) b;
}
struct B (uint D)
{
uint [D] data;
uint foo () { return data [0]; }
}
alias B! (3) b3;
alias B! (4) b4;
The error goes away if the "alias B! (3) b3;" line is removed, the
"alias B! (D - 1) b;" line is removed or changed to "alias B! (3) b;",
or the "uint foo () { return data [0]; }" line is changed to "uint foo
() { return this.data [0]; }".
Another variant that works is to change the "alias B! (3) b3;" line to
"alias B! (4) b4;" and to change the "alias B! (D - 1) b;" line to
"alias B! (D) b;". So it seems to be an interaction between constant
folding and aliasing.
Whoops, scratch that. The problem is NOT fixed in 0.133 (I tested a
fixed copy by mistake), AND I posted the wrong example. It should
instead be:
struct A (uint D)
{
alias B! (D - 1) b;
}
struct B (uint D)
{
uint [D] data;
uint foo () { return data [0]; }
}
alias B! (3) b3;
alias A! (4) a4;
One little letter at the end.
Sep 26 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Burton Radons schrieb:
Whoops, scratch that. The problem is NOT fixed in 0.133 (I tested a
fixed copy by mistake), AND I posted the wrong example. It should
instead be:
struct A (uint D)
{
alias B! (D - 1) b;
}
struct B (uint D)
{
uint [D] data;
uint foo () { return data [0]; }
}
alias B! (3) b3;
alias A! (4) a4;
One little letter at the end.
Added to DStress as
http://dstress.kuehne.cn/run/t/template_class_10_A.d
http://dstress.kuehne.cn/run/t/template_class_10_B.d
http://dstress.kuehne.cn/run/t/template_class_10_C.d
http://dstress.kuehne.cn/run/t/template_class_10_D.d
http://dstress.kuehne.cn/run/t/template_class_10_E.d
http://dstress.kuehne.cn/run/t/template_struct_03_A.d
http://dstress.kuehne.cn/run/t/template_struct_03_B.d
http://dstress.kuehne.cn/run/t/template_struct_03_C.d
http://dstress.kuehne.cn/run/t/template_struct_03_D.d
http://dstress.kuehne.cn/run/t/template_struct_03_E.d
Thomas
-----BEGIN PGP SIGNATURE-----
iD8DBQFDOGgX3w+/yD4P9tIRArnTAKCEmuPiHFj2Ij3y68wTvozz2bGEuACeICRe
eAj1yJRnUsujL+alq64Zfl0=
=ql3Z
-----END PGP SIGNATURE-----
Sep 26 2005









Burton Radons <burton-radons smocky.com> 