@newt @GNUxeava unlike Go it doesn't have a spec , and cannot seem to find that paper anywhere on Rust's site

@novaburst @GNUxeava C and C++ do have specs, but they are so poorly written that even compiler writers sometimes misinterpret them. And then you need a metric shitton of flags to compile most C code because it deviates from that spec. Standards are useless if nobody follows them. So screw that argument, it’s just lame.

@newt @GNUxeava @novaburst No, it's not. Show me where the spec is confusing dii.uchile.cl/~daespino/files/
And 99% of C programs are compiled with just -Wall and whatever -Is, -Ds, and -ls you need. Maybe you add -std= if you want to be pedantic, but it almost always works

@applejack @GNUxeava @novaburst are you sure you wanna have this argument? Let's have one.

First, how come most GNU code (take GTK, for one) requires -fno-strict-aliasing?

Second, if you zero a structure and then set some of the fields, will the padding bits all be zero? This one is my favorite. Try reading the C spec about it and come up with an answer.

Third, this is the fun part. Can the results of two calls to malloc() ever be equal?
Follow

@newt @GNUxeava @novaburst Compilers give you a warning when aliasing so you can give it the correct option. That's not a problem, nor typical.
The compiler might play with the padding bits to optimise the behaviour. That's explicit. Undefined behaviour lets the implementation make the most appropriate choice for speed.
Mallocs can be the same between processes because of paging, and if they both return NULL, otherwise it's unique (according to man malloc), obviously.

If you think undefined behaviour means poorly written, you're very confused. None of those are things the average user will ever run into btw.

· · Web · 1 · 0 · 0
@applejack @GNUxeava @novaburst nope, compilers don’t give a warning when aliasing.
Compilers may insert padding, but my question is different. The thing is, this is VERY vaguely described in the standard. Because, as I mentioned earlier, it’s very poorly written.

And the whole thing with undefined behavior may have produced performance benefits 40 years ago, but in the day and age it’s more of a headache and a security nightmare.

@newt @GNUxeava @novaburst No, it's not. It's explicit about what is undefined behaviour.

If you don't have padding bits, you can't treat the struct as a whole block. If you have to leave the padding bits alone, then you can't do something like setting a whole block of memory when setting multiple values in fewer instructions. There's no way to solve this without being slower, nor do you ever care about the padding bits.

If your goal is security the entire thing is thrown out the window from having retarded amounts of code (plus npm levels of package bloat and quality) that might at any point call an unsafe block of code. You should write it in an *actually* safe language, or just use static analysis tools, which is basically what rust is. C++ with somehow shittier syntax and the slowest static analyser in the world.

@applejack @GNUxeava @novaburst look, I asked you a simple question about struct padding and you ended up sperging about undefined behavior and what not. This isn’t fun :comfyeek:
Sign in to participate in the conversation
Game Liberty Mastodon

Mainly gaming/nerd instance for people who value free speech. Everyone is welcome.