1

Is there any disadvantages or pitfalls with migration to c++11, if my current project on c++98? I mean that at some point I will start to use some advantages like auto etc. from c++11 and will not do anything with the previous written code?

Seems only one disadvantage that its will be impossible to compile the projects on the servers with the old gcc? For example, I'm on FreeBSD 7, and there is no official new gcc for it.

UPDATE: @nurettin wrote on the comments that need to compile somewhere on c++11 and test it, but the application is very specifically and hard to test. it's background daemon without any output to console (something like web server with many thread) so it's very hard to debug....

quetzalcoatl
  • 32,194
  • 8
  • 68
  • 107
abrahab
  • 2,430
  • 9
  • 39
  • 64
  • There are some breaking changes in C++11, such as `explicit bool` for smart pointers. Have you tried building the project as C++11? – Yakk - Adam Nevraumont Feb 15 '14 at 07:51
  • 2
    A lot of specs have changed. You might run into standard library issues such as [vector push_back not being properly inlined](http://stackoverflow.com/questions/20977741/stdvector-performance-regression-when-enabling-c11). It is a good idea to just compile with C++11 flag and run the profiling tools to see if anything changed for the worse. – nurettin Feb 15 '14 at 07:51
  • @nurettin check my update. so, really seems it's very hard to profile with some tools... :( and the real project with real values/traffic working on the server with FreeBSD 7 and I can not use for example `valgrind` because it's have the bug on this OS – abrahab Feb 15 '14 at 07:58
  • 1
    Potentially, the implicit `noexcept` specifications could affect runtime behaviour under exceptions. Plus implicit move constructors *might* break some exception safety in std lib containers in the case of exceptions. – juanchopanza Feb 15 '14 at 08:27
  • 2
    It's a bad idea to change code that is currently "working" but hard to test, just to use the latest revision to a language. Your time is probably better spent writing automated tests as this will help you with your current code base and will make things easier in the future when you decide to migrate to C++11. – CadentOrange Feb 15 '14 at 08:54
  • 1
    Looking at some of my older C++03 code, and now understanding prefect forwarding, rvalue references, move semantics, the richer standard library and other improvements in C++11, it seems worthwhile to carefully examine the old sources and watch for optimization and simplification opportunities. Of course, that shouldn't be "high priority" ;) – CouchDeveloper Feb 15 '14 at 09:46
  • @CouchDeveloper but need to know new features of C++11 also :) at this time I know only `auto` and maybe some new functions like `to_string`.. How you retrained c++ to know new standard and all new features? – abrahab Feb 15 '14 at 13:24

1 Answers1

2

Explicit operator bool is a major breakdown regarding compatibility.

However if you want to know all the nuances and changes for the new version I recommend you checking the ISO C++ committee approved Final Draft International Standard (FDIS) for the C++ programming language. It has a section for incompatibilities at appendix C.2 "C++ and ISO C++ 2003"

Some of them are summarized in this answer on SO.

I can summarize some common pitfalls for you:

  • Watch out for new keywords, string literals and other core differences in the syntax of the language e.g.

    #define u8<-- "abc"
    
  • Destructors are now implicitly "no-throw" (and frankly throwing exceptions from destructor is a terrible practice)

  • Functions with internal linkage are considered when searching for dependencies as well

Community
  • 1
  • 1
Marco A.
  • 43,032
  • 26
  • 132
  • 246