Movement against float.init being nan

Steven Schveighoffer schveiguy at gmail.com
Wed Aug 24 00:00:51 UTC 2022


On 8/23/22 6:33 PM, Walter Bright wrote:
> On 8/23/2022 1:44 PM, Dave P. wrote:
>> What’s great is that structs defined in C imported in D and structs 
>> defined in D imported in D will have completely different initial 
>> values despite being syntactically identical!
> 
> Let's have some fun with the following C program:
> 
> -----------
>   #include <stdio.h>
> 
>   struct Foo { float x; };
> 
>   int main()
>   {
>      struct Foo f;
>      printf("%g\n", f.x);
>   }
> 
>   gcc test.c
>   ./a.out
>   2.12133e-15
> -------------
> 
> Oh well!

Since you are looking at it, the original code is *not* a C function, 
it's a D function using a struct defined using C (imported via ImportC).

What happens in that case?

On one hand, it's a C struct. But on the other hand, it's a D function. 
Who's rules are used?

-Steve


More information about the Digitalmars-d mailing list