clang++ only compiles C++11 program using boost::format when -std=c++11 option is dropped

StackOverflow https://stackoverflow.com/questions/23462950

  •  15-07-2023
  •  | 
  •  

Domanda

Please take a look at the following C++11 snippet:

#include <boost/format.hpp>

int main(int argc, char** argv)
{
  auto s = boost::format("");
  return 0;
}

When I compile it with clang using the -std=c++11 I get the following error:

$ clang++ -std=c++11 -o main main.cpp
In file included from main.cpp:1:
In file included from /usr/include/boost/format.hpp:19:
In file included from /usr/include/boost/detail/workaround.hpp:41:
In file included from /usr/include/boost/config.hpp:40:
In file included from /usr/include/boost/config/select_stdlib_config.hpp:18:
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../include/c++/4.9.0/cstddef:51:11: error: 
      no member named 'max_align_t' in the global namespace
  using ::max_align_t;
        ~~^
1 error generated.

Without the -std=c++11 everything compiles fine, but clang prints a warning:

$ clang++ -o main main.cpp
main.cpp:5:3: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
  auto s = boost::format("");
  ^

So, it looks like a valid workaround is to drop the C++11 flag, as the current version of clang seem to be in C++11 mode, anyway? The drawback is that you will get many warnings.

Is there a better workaround beside completely switching to gcc? Patching the source code of boost::format or gcc-libs is fine for me.


System information:

  • Platform: Arch Linux x86_64
  • Boost version: 1.55.0-6
  • gcc-libs: 4.9.0-1
  • clang++: 3.4 (tags/RELEASE_34/final)
È stato utile?

Soluzione

The bug is closed now. It should be fixed in Arch with clang 3.4-2.

With this commit, Evangelos Foutras merged the following patch from upstream: http://reviews.llvm.org/rL201729

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top