You're telling the function you're calling that your pointer points to memory that has enough room to store a double, but the actual memory is only big enough for a float.
Getting zero back is the least of what could go wrong - you are corrupting the stack. The additional 32 bits of the double are being written to whatever comes after the space reserved for your float. Most likely problem is that you'll overwrite a different local variable in your function, but you could also overwrite the saved frame pointer or return address.
Stack view for this scenario on x86/x64:
+-----------------+
| |
| +------------------+
| | | |
<- glfwGetCursorPos locals | ptr window | ptr &x | ptr &y | float x | float y | ptr {rBP} | ptr retAddr |
( pushed call arguments )
( your locals )
( return to whoever called you )
Write to *x overwrites both x and y: | *x as double |
Write to *y overwrites both y and rBP: | *y as double ------|
rBP = EBP on x86, RBP on x64, optional if you have "omit frame pointer" turned on. If that's the case you'll stomp retAddr instead.
On x64, RBP and the return address are 64-bit and you'll overwrite half of them with part of your double.
On x86, EBP and the return address are 32-bit and you'll completely overwrite them with the second half of y.
In your calling function, your local variables that you take the address of must be doubles. You can cast them to float *after* you get them back.
If your function has other local variables besides just x and y, they will be somewhere on the stack as well, and could be getting overwritten instead of rBP/retAddr.
(edited like 50 times: ASCII art is a pain)