Same code, different behaviour between Linux and Mac

I’m having a strange issue with std::regex in an addon. On macOS, with Clang, everything works as expected. On Linux, using Qt Creator, I’ve a different behaviour, and my regular expression does not work properly. I’ve read that regular expression are not correctly implemented in gcc <= 4.9, but the output of gcc -v tells me that my current version is gcc version 4.9.3 (Ubuntu 4.9.3-8ubuntu2~14.04). My questions is:

  • What is the compiler normally used with OF on linux? are usually people on Linux using gcc instead of clang? if yes, why?
  • How can I be sure that QT creator is using the compiler that I want?
    This is what I see actually in the tools -> compilers tab:

and this is the output of sudo update-alternatives --config gcc

sudo update-alternatives --config gcc
There is only one alternative in link group gcc (providing /usr/bin/gcc): /usr/bin/gcc-4.9
Nothing to configure.

Can I safely assume that qt creator is using g++ 4.9.3 ?

just for the record, this c++ code:

#include <iostream>
#include <string>
#include <regex>

int main() {
  std::string _str, reg;
  _str = "F[-F]";
  reg = "([A-Z|\\^|&|\\+|-|\\?|\\||\\]|\\[|/|\\\\])";
  std::smatch match;
  std::regex regEx(reg);
  std::stringstream buffer;

  auto wordsBegin = std::sregex_iterator(_str.begin(), _str.end(), regEx);
  auto wordsEnd = std::sregex_iterator();
  for(std::sregex_iterator i = wordsBegin; i != wordsEnd; ++i){
      std::smatch m = *i;
      buffer << m.str();
  std::cout << "Hello, " << buffer.str() << "!\n";

is returning “Hello, F[F]” with gcc 4.9.3 and “Hello F[**-**F]” with clang.

I’ve find the solution to my problem in this thread

The snippet in the previous post gives back “Hello F[-F]” only if compiled with clang and the following options:
clang++ -std=c++11 -stdlib=libc++ test.cpp

Without the flag -stdlib=libc++ that snippet returns “Hello F[F]” also with clang. the libc++ exist only with clang, in g++ it is called libstdc++. They are not ABI compatible.

I do not know if it can be useful but if you work without qtcreator you can use makefiles and configure new link populating this variable PROJECT_CFLAGS = -std=c++11 in config.make to add addons edit instead addons.make

good day