Mercurial > projects > dstress
view nocompile/bug_mtype_3154.d @ 1550:f46f0b6ed2d1
[Issue 627] Concatenation of strings to string arrays with ~ corrupts data
Matti Niemenmaa <deewiant@gmail.com>
2006-12-02
http://d.puremagic.com/issues/show_bug.cgi?id=627
author | thomask |
---|---|
date | Mon, 23 Jul 2007 18:42:04 +0000 |
parents | 774e02c900da |
children |
line wrap: on
line source
// $HeadURL$ // $Date$ // $Author$ // @author@ Daniel Horn <hellcatv@hotmail.com> // @date@ 2004-04-30 // @uri@ news:c6ullo$104s$1@digitaldaemon.com // @uri@ http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D.bugs&artnum=48 // __DSTRESS_ELINE__ 51 module dstress.nocompile.bug_mtype_3154; struct vec(VALUE, int size){ enum {nvalues=1} VALUE [size]f; VALUE* getAt(uint i) { return i<size?&f[i]:&f[size-1]; } VALUE opIndexAssign(uint i, VALUE v) { return (*getAt(i))=v; } VALUE opIndexAssign(uint i) { return i<size?f[i]:f[size-1]; } template T(zvec) { zvec castTo() { zvec ret; for (int i=max(ret.nvalues-1,size-1);i>=0;i--) { ret[i]=this[i]; } return ret; } } } alias vec!(float,1) float1; alias vec!(float,4) float4; int main (char[][]args) { float1 a; float4 b; b[0]=1,b[1]=2,b[2]=3,b[3]=4; a[1]=3; b=a.T(float4).castTo();// <-- taking out this line stops the error return 0; }