G++ 5.4 does not compile some C++11 code without workaround flag

Bug #1739778 reported by Mateusz Szychowski
18
This bug affects 2 people
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

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in gcc-5 (Ubuntu):
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.