3 ms·
What's considered critical or difficult to discover is a bit subjective, but: It's easy to forget that alignment is important on some architectures (other than
by BudVVeezer 10y ago
What's considered critical or difficult to discover is a bit subjective, but:
It's easy to forget that alignment is important on some architectures (other than for performance reasons), so be careful when using placement new:
https://www.securecoding.cert.org/confluence/display/cplusplus/MEM54-CPP.+Provide+placement+new+with+properly+aligned+pointers+to+sufficient+storage+capacity https://www.securecoding.cert.org/confluence/display/cpluspl...
This may seem obvious, but even the C++ committee got this one wrong when they created auto_ptr (which has since been removed from the standard):
https://www.securecoding.cert.org/confluence/display/cplusplus/OOP58-CPP.+Copy+operations+must+not+mutate+the+source+object https://www.securecoding.cert.org/confluence/display/cpluspl...
This one is totally obvious but has a stunning number of ways you can fail to adhere to it, some of which look reasonable at first blush:
https://www.securecoding.cert.org/confluence/display/cplusplus/EXP54-CPP.+Do+not+access+an+object+outside+of+its+lifetime https://www.securecoding.cert.org/confluence/display/cpluspl...
- duneroadrunner 10y ago> This one is totally obvious but has a stunning number of ways you can fail to adhere to it, some of which look reasonable at first blush If memory safety is actually important to you, there's now an actual practical solution: SaferCPlusPlus[1]. A tool to automatically retrofit memory safety to existing C/C++ code is in early development (but resources are limited so it might be a while). [1] shameless plug: https://github.com/duneroadrunner/SaferCPlusPlus https://github.com/duneroadrunner/SaferCPlusPlus