G++ 5.4 does not compile some C++11 code without workaround flag
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
gcc-5 (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
Simple C++ code example to trigger this error:
#include <string>
#include <iostream>
int main()
{
std::cout << std::to_string(4) << std::endl;
return 0;
}
Building with:
g++-5 -std=c++11 main.cpp -o main
will yield this error:
main.cpp: In function 'int main()':
main.cpp:6:16: error: 'to_string' is not a member of 'std'
std::cout << std::to_string(4) << std::endl;
^
however when building with "D_GLIBCXX_USE_C99" flag it works:
g++-5 -D_GLIBCXX_USE_C99 -std=c++11 main.cpp -o main
I do not think it should be necessary to provide this flag, especially when G++ 5.4 does not need this flag on other distributions, std::to_string was introduced in C++11, so -std=c++11 should be enough.
This was tested on Ubuntu 17.10
Status changed to 'Confirmed' because the bug affects multiple users.