Earlier quoted context omitted.
union foo { int x; float y; }; union foo bad; bad.x = 100; printf("%f\n", bad.y); // undefined behavior (though usually works)
No undefined behavior. Perfectly legal since C99 standard.
Things Rust shipped without
11–20 of 330 posts
Re: Things Rust shipped without
#12Re: Things Rust shipped without
#13Earlier quoted context omitted.
In C you can store a value to a field of a union and then read from a different field. This is usually done to "get the byte representation of a float" or things like that. Except... it's undefined behavior.
> Except... it's undefined behavior. No longer true since C99.
Re: Things Rust shipped without
#14What about things that Rust shipped without that should have been included?
Re: Things Rust shipped without
#15Earlier quoted context omitted.
No undefined behavior. Perfectly legal since C99 standard.
Can we please get a quote on this one. If reinterpreting memory via a union is valid in C99, including data vs function pointers, then so would reinterpreting that memory via a cast, which would seem to violate one of the most elementary aspects of the standard (e.g. such a rule would be difficult or impossible to implement on a Harvard architecture machine, which the standard previously made plenty of allowance for)
[1]: http://dbp-consulting.com/tutorials/StrictAliasing.html
Re: Things Rust shipped without
#16> goto (not even as a reserved word) I haven't done this for a while, but once upon a graduate program I wrote a compiler from a made-up-language (MUP) to C. MUP had some strange control structures, and if C did not have "goto", it would have been a lot more difficult to implement those structures. Since then, I have always thought languages should have a "goto" statement that human-written code is not allowed to use…
Re: Things Rust shipped without
#17What about things that Rust shipped without that should have been included?
Re: Things Rust shipped without
#18Language creators won't endear themselves to me by ranting. The problem I have with Rust is _not_ the language itself.
Re: Things Rust shipped without
#19What about things that Rust shipped without that should have been included?
Incremental compilation and a non-braindead module system. Breaking changes will be required to fix both, which is why Rust was released too early if you ask me.
I'd also question why the module system is "braindead", of course.