safety and auto vectorization
Bruce Carneal
bcarneal at gmail.com
Mon Aug 3 19:22:07 UTC 2020
On Monday, 3 August 2020 at 18:55:36 UTC, Steven Schveighoffer
wrote:
> On 8/2/20 1:31 PM, Bruce Carneal wrote:
>> import std;
>>
>> void f0(int[] a, int[] b, int[] dst) @safe {
>> dst[] = a[] + b[];
>> }
>>
[snip of auto-vectorization example]
>>
>> I was surprised that f0 ran just fine with a.length and
>> b.length geq dst.length. Is that a bug or a feature?
>>
>
> First, I think this is a bug. A regression in fact. As of 2.077
> this works, and before it did not. There is nothing in the spec
> that says the behavior is defined for this case.
>
> Second, it's more than just that. This also runs currently:
>
> void main()
> {
> auto a = [1, 2, 3];
> auto b = [4, 5, 6];
> int[] dst = new int[4]; // note the extra element
> dst[] = a[] + b[];
> writeln(dst[3]);
> }
>
> Prior to 2.077, this fails with array length problems.
>
> After that it prints (at the moment): 402653184
>
> If I up the size to 5, it fails with a range violation. I
> strongly suspect some off-by-one errors, but this looks unsafe.
>
> -Steve
Thanks Steve (and Chad). Summary: underspecified, varying
behavior across versions, buggy.
Steve, what's the best way for me to report this? Are spec
issues lumped in with the other bugzilla reports?
More information about the Digitalmars-d-learn
mailing list