Obscure c++ features
Posted: Fri Apr 19, 2013 2:22 pm
So I came across this post today and read the "Redefining keywords section". I thought to myself: "No way, this just can't be true". But behold, it is valid gcc4.6 code:
#define private public class A { private: int a; }; int main() { return A().a; }
$ g++ --version; g++ -o test test.cpp && ./test; echo $? g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 Copyright (C) 2011 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 0