The following code fails with an assertion failure when it clearly shouldn't: ==================================================== void main() { float[64] array; int i = 42; auto slice = array[]; slice[] *= 2f; assert(i == 42); } ==================================================== Array bounds checking doesn't catch this. I presume that the code in the runtime to execute this array operation is buggy.
Created attachment 548 [details] patch against druntime to fix the problem
Yes, it is buggy. I've uploaded a patch to fix the routine which does float array times scalar multiplication, though probably it's a better idea to file it at druntime directly. I'll crosspost it there.
I've realized that the other float array operations of the form "array op= scalar" suffer from the same problem. Please hold off with applying this patch, I'll provide a more general one. I hope string mixins are ok to use in druntime? There's quite a lot of code duplication in these array modules.
I submitted the patch to Tango (since that's what I use currently), it was folded into their copy of the runtime. I would appreciate if someone merged the changes into druntime to keep them in lockstep. Patch and discussion are here: http://www.dsource.org/projects/tango/ticket/1831
The original test case passes on D2, but here's a test case which fails on both D1 and D2. ------ void main() { float[66] array; array[] = 0; array[64] = 42; array[65] = 43; array[0..64] *= 2f; assert(array[65] == 43); assert(array[64] == 42); } ------
Changes checked into druntime svn 234 and D1 phobos svn 1403.
fixed dmd 1.056 and 2.040
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル