4 ms·
Accesses - pointers - are automatically nulled when declared. So you won't silently screw up who-knows-what with an uninitialized access, though yeah, it's not
by foerbert 6y ago
Accesses - pointers - are automatically nulled when declared. So you won't silently screw up who-knows-what with an uninitialized access, though yeah, it's not perfectly safe.
- MaxBarraclough 6y agoI didn't mean pointers/access-types, I meant ordinary integer-type locals.
- pjmlp 6y agoYou can put a pragma Warning_As_Error ("never assigned"); or the respective compiler switch on GNAT. Other compilers have similar switch. Heck even C and C++ have them, although few make use of them.
- touisteur 6y agoPragma Initialize_scalars for the win. But at runtime. And if you can afford it, Codepeer (static analysis) finds most of the ones the compiler doesn't find. And then if you can live with the Spark subset, you get proof of initialization in 'bronze' mode :-).
- MaxBarraclough 6y agoAlso, I think Ada is fully memory-safe but for initialization. That is to say, the only way in which it's not memory-safe, is regarding uninitialized variables. (That's assuming of course that you don't disable checks.) I'm not sure if it lets you shoot yourself in the foot regarding invalid type conversions, misuse of unions, that kind of thing.
- okl 6y agohttps://www.adacore.com/uploads/techPapers/rtchecks.pdf https://www.adacore.com/uploads/techPapers/rtchecks.pdf
- okl 6y agoYou can also declare access types as "not null" in which case initialization is compulsory. http://www.ada-auth.org/standards/12rm/html/RM-3-10.html#p13.1 http://www.ada-auth.org/standards/12rm/html/RM-3-10.html#p13...