3 ms·
Logic inversion should normally be caught rather easily, flow control misdirections not so much : #define if while . My favorite (C++) : #define private public
by luch 13y ago
Logic inversion should normally be caught rather easily, flow control misdirections not so much : #define if while .
My favorite (C++) : #define private public
- twoodfin 13y agoMy favorite (C++) : #define private public Unless I'm mistaken, C++ was (deliberately) specified in such a way that such a redefinition does not affect the behavior of (most) already valid code. Access control doesn't affect overload resolution, for example. I had to add the (most) qualifier because I bet dynamic_cast<> and other RTTI mechanisms would achieve different runtime results against some classes if private inheritance became public. Also, I believe that C++ forbids preprocess munging of keywords under penalty of undefined behavior if you include any standard headers, so anything could happen in most modules.
- npsimons 13y agoUnless I'm mistaken, C++ was (deliberately) specified in such a way that such a redefinition does not affect the behavior of (most) already valid code. Perhaps it doesn't change the implementation, but I know I've used the above trick to get access to private functions for unit testing (yes, yes, I know you "should" only test interfaces, or make internal tests; spare me and realize it's useful: http://mrzechonek.github.io/tut-framework/faq.html#can-we-test-private-methods http://mrzechonek.github.io/tut-framework/faq.html#can-we-te...)
- ape4 13y agoFunny. Also subtle redefining of Linux commands tar -> zip.