back

by AlexeyBrin·10y ago·view on hn ↗
Personally I never seen a C++03 program that doesn't compile in C++11/14.

Obviously, if you are talking about C++ code written before C++ was standardized, like in the 90's, you are probably right.

2 comments
I've seen and ported such programs. I no longer remember what the problems were, but I think some of them had to do with array initializers - C++11 seems to have become stricter wrt implicit casts of values used to initialize arrays (meaning that more casts need to become implicit.)

Perhaps it's a compiler issue, not a language issue; my only point is that the issue exists (and I'm not saying it was that terrible - I recommend everyone to upgrade to C++11 - just that code will not compile unchanged.)

Sister comments say that they have old C++ code that compiles just fine. Of course such code exists, I'm just saying that not all code is like that; I bet you can get there with Rust or some other reasonably stable new language if you program conservatively enough. Also a big question is what platform your code runs on; if you've targeted gcc since forever and you don't use -Werror, then your code and your Makefiles will be very stable relatively to having to port to VS - even if you're not really targeting standard C++ but the dialect GNU C++. Different C++ compilers, build environments and platform libraries are very different, and it seems a safe bet that newer languages will do a better job of minimizing differences between implementations (or keeping their number small.)

Porting C++ code compiling fine under g++ to clang, for instance, is a metric ton of work (and this one I gladly wasn't involved in but I've seen others do it; again, if your C++ code ports just fine, more power to you.) And g++ and clang are much closer to each other than the average pair of C++ compilers.

I've "ported" ~200k lines of C++03 to C++11 and so far I've had to make exactly one change due to language changes (C++11 forbids narrowing conversions in braced inits, while C++03 just did nonsensical things). That's not to say that no other changes were required, but the rest were things like fixing code that had both C++03 and C++11 versions and the C++11 version was broken, and fixing compatibility issues with libc++.