Post

Replies

Boosts

Views

Activity

Apple clang version 12.0.0 (clang-1200.0.32.28) issue
I have some difficulties regarding codes that were working correctly on previous CLANG compilers and are working with no issue on other GNU, older CLANG, ... C++ compilers e.g., #include <iostream> #include <sstream> #include <string> #define SNUM(x) static_cast<std::ostringstream &>(std::ostringstream() << std::dec << x).str() int main() { &#9;&#9;&#9;&#9;int n = 100; &#9;&#9;&#9;&#9;std::string s = "matrix (of size N=" + SNUM(n) + ")"; &#9;&#9;&#9;&#9;std::cout << s << std::endl; } it is working as supposed with, >> g++ test.cpp >> ./a.out matrix (of size N=100) But it fails with c++11, >> g&#92;&#43;&#92;&#43; -std=c++11 test.cpp test.cpp:7:41: error: non-const lvalue reference to type 'basic_ostringstream<...>' cannot bind to a temporary of type 'basic_ostringstream<...>' &#9;&#9;&#9;&#9;std::string s = "matrix (of size N=" + SNUM(n) + ")"; &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; ^~~~~~~ test.cpp:4:17: note: expanded from macro 'SNUM' #define SNUM(x) static_cast<std::ostringstream &>(std::ostringstream() << std::dec << x).str() &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;^&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated. The compiler is, >>g&#92;&#43;&#92;&#43; --version Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1 Apple clang version 12.0.0 (clang-1200.0.32.28) Target: x86_64-apple-darwin20.2.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin
3
0
5.8k
Jan ’21