Re:System programming in Rust: beyond safety
by jhomedall on Thursday June 15, 2017 @10:32AM
(#14560724)
Deterministically locating all undefined behavior is undecidable. Static analyzers can only locate a subset of it.
Commonly-used type punning techniques frequently exhibit undefined behavior due to strict aliasing: https://blog.regehr.org/archives/1307 .
Re:System programming in Rust: beyond safety
by nickpsecurity on Thursday June 15, 2017 @11:38AM
(#14561375)
"Deterministically locating all undefined behavior is undecidable. Static analyzers can only locate a subset of it."
It might be true but barely matters when we have tools like KCC. It's built on an executable semantics of C that runs in a framework on top of Maude rewrite engine.
http://www.kframework.org/index.php/Main_Page
https://github.com/kframework/c-semantics
http://fsl.cs.illinois.edu/FSL/papers/2015/hathhorn-ellison-...
Re:System programming in Rust: beyond safety
by jhomedall on Thursday June 15, 2017 @11:55AM
(#14561549)
That's fascinating; thank you for that. I often find academic papers are too densely written to me to read, but the authors of that paper have gone out of their way to describe everything in a straightforward manner.
Yes, things like memcpy and printf are (in most cases) built-in in compilers. Not surprising really.
Undefined behavioral is bad programming, if your ask me. Almost all examples of it, that i ran across, are in really ugly code that only a "smart" programmer would write.
Clangs static analyzer points out undefined behavior, and gcc is close to getting a "-Wundefined" flag that points that out at compile time.
A optimizing C compiler can change the resulting code even more then just doing dead code elimination. But the point still stands, that C maps well to assembly and that languages that do things like their own memory allocation are not even comparable to what the cpu provides (only automatic memory allocation that a cpu somewhat provides is the stack, and C exposes even that).