[Bug 152] New: static assert fails with recursive templates
Thomas Kuehne
thomas-dloop at kuehne.cn
Wed May 24 09:31:08 PDT 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
d-bugmail at puremagic.com schrieb am 2006-05-23:
> This hangs until the stack overflows:
>
> template hang(int i)
> {
> static assert(0);
> const int hang = hang!(i-1);
> }
> const int x = hang!(1);
>
> This correctly asserts:
>
> template hang()
> {
> static assert(0);
> const int hang = hang!();
> }
> const int x = hang!();
>
> My guess is that the static assert is evaluated after the next hang!(i)
> is evaluated (e.i. never) If a terminating case is added and a pragma(msg,"")
> put in, only the terminating case gets the assert.
Added to DStress as
http://dstress.kuehne.cn/nocompile/a/assert_15_A.d
http://dstress.kuehne.cn/nocompile/a/assert_15_B.d
http://dstress.kuehne.cn/nocompile/a/assert_15_C.d
http://dstress.kuehne.cn/nocompile/a/assert_15_D.d
Thomas
-----BEGIN PGP SIGNATURE-----
iD8DBQFEdC333w+/yD4P9tIRAvryAJ0V//ccGr/fC350nW/Pd/2G91IGmQCg0oNc
qeGu+jyY3gONa6IWvh398Tk=
=3ub6
-----END PGP SIGNATURE-----
More information about the Digitalmars-d-bugs
mailing list