-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix warning on 4.10 #766
Comments
For reasons I'm not very clear on this is actually an error (not a warning) for the Fedora build. It may be that the Fedora build system is adding some hardening flags which causes this. |
I suggested changing |
I just added the cast in a branch, will merge after CI. By the way, the original patch filename weakly implied that this was caused by Lwt 5.1.2. In fact, it has been in Lwt for a very long time. 5.1.2 is just the first release after OCaml 4.10 was released. It is OCaml 4.10 that caused this. |
I'll retag the 5.1.2 release, since it's stalled in opam's CI anyway. |
the issue with a cast from |
I guess in the future if the OCaml compiler decided to allocate strings in the text segment, this could actually fail. I don't think it does at the moment. |
Do you have a reference for why and what exactly is UB? Is the actual cast operation UB, or is the argument about the effect of treating the underlying data "unsafely?" Also note that, at the moment, #define String_val(x) ((const char *) Bp_val(x))
#define Bp_val(v) ((char *) (v)) Is there a C implementation on which |
@hannesm See commit attached above. |
I don't have an authoritative reference, sorry. But https://en.wikipedia.org/wiki/Const_%28computer_programming%29#Loopholes_to_const-correctness says "Writing into a const variable this way may work as intended, but it causes undefined behavior and seriously contradicts const-correctness". Thanks. |
This part of the Wikipedia article needs some editing attention :p What ultimately convinced me is @rwmjones' last comment about the representation of strings potentially changing. Even if their storage doesn't move to a read-only section like |
See https://travis-ci.org/ocsigen/lwt/jobs/654080430#L430.
Made slightly difficult by that
Bytes_val
was added in 4.06.The text was updated successfully, but these errors were encountered: