Unexplainable behaviour with direct struct assignment.
H. S. Teoh
hsteoh at quickfur.ath.cx
Wed May 18 20:14:24 UTC 2022
On Wed, May 18, 2022 at 08:05:05PM +0000, HuskyNator via Digitalmars-d-learn wrote:
[...]
> ```d
> module app;
> import std.stdio;
>
> struct A {
> float[1] vec;
> this(float[1] n) {
> this.vec = n;
> }
> }
>
> void main(string[] args) {
> A c = A([50.0f]);
> writeln(c.vec[0]);
>
> A b = A([50.0f]);
> writeln(b.vec[0]);
>
> c = A([50.0f]);
> writeln(c.vec[0]);
> }
> ```
>
> This will print:
> ```
> 0
> 50
> nan
> ```
[...]
Can't replicate this problem. On my local machine (Linux/64), I get the
output:
````
50
50
50
````
What's the exact compile command you're using?
T
--
To err is human; to forgive is not our policy. -- Samuel Adler
More information about the Digitalmars-d-learn
mailing list