On Sunday, 26 January 2025 at 12:45:11 UTC, John C. wrote:
Hello everyone. I am complete newbie in D and programming at
all and I can't understand why dynamic arrays can't be used
within following D code:
```d
import std.random : uniform01;
import core.simd;
void main() {
align(32) float[] a = new float[128];
...
```
The `align(32)` applies to the slice `a`, not the contents of `a`
(where `a` points to).
Some things to try:
- What exactly is the error reported? An out-of-bounds read/write
would not result in a segfault. (but perhaps with optimization
and UB for unaligned float8 access...)
- Print out the pointer to `a[0]` to verify what the actual
alignment is.
- Does it work when you create an array of `float8`? (`float8[]
a = new float8[128/8];`)
By the way, `a[i], b[i] = uniform01(), uniform01();` does not do
what you think it does. Rewrite to
```
a[i] = uniform01();
b[i] = uniform01();
```
cheers,
Johan