[Github-comments] [geany/geany-plugins] Scope breaks nightly with gcc 8 (#794)

Colomban Wendling notifications at xxxxx
Thu Nov 29 22:02:33 UTC 2018


You found it yourself, but basically the thing is that the C standard doesn't enforce much on pointer sizes.  The only (IIRC) thing that it requires is that a pointer to `void` can hold any other *data* pointer, and that a cast back to the original type yields the same pointer (and that `intptr_t` has the same kind of properties).  Anything further is implementation defined.

As said, in most common situations (your computer, mine, etc.), all pointers can be happily casted between different types back and forth, even function pointers.  But the C standard allows this not to be the case.
The following *could* result in undefined behavior:
```C
float f1 = 4.2f;
float *fp = &f1;
int *ip = (int*)fp;
float f2 = *((float*)ip);
// whether f1 == f2 is implementation defined
```

But again, as @elextr just said, we probably don't really have to worry about that.  And yeah things like `dlsym()` basically require `void*` to be able to hold a function pointer as well.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany-plugins/issues/794#issuecomment-443010169
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20181129/a407420a/attachment.html>


More information about the Github-comments mailing list