type main.cpp
#include <iostream>
#include <string>
int main()
{
std::string x = std::to_string(22.2f);
std::cout<<x<<std::endl;
return 0;
}
4.Other:Dev/cpp11> g++ -std=c++11 -athread=native -o main main.cpp
main.cpp: In function 'int main()':
main.cpp:6:39: error: call of overloaded 'to_string(float)' is ambiguous
6 | std::string x = std::to_string(22.2f);
| ~~~~~~~~~~~~~~^~~~~~~
In file included from /Programs/SDK/gcc/include/c++/11.1.0/string:55,
from /Programs/SDK/gcc/include/c++/11.1.0/bits/locale_classes.h:40,
from /Programs/SDK/gcc/include/c++/11.1.0/bits/ios_base.h:41,
from /Programs/SDK/gcc/include/c++/11.1.0/ios:42,
from /Programs/SDK/gcc/include/c++/11.1.0/ostream:38,
from /Programs/SDK/gcc/include/c++/11.1.0/iostream:39,
from main.cpp:1:
/Programs/SDK/gcc/include/c++/11.1.0/bits/basic_string.h:6649:3: note: candidate: 'std::string std::__cxx11::to_string(int)'
6649 | to_string(int __val)
| ^~~~~~~~~
/Programs/SDK/gcc/include/c++/11.1.0/bits/basic_string.h:6660:3: note: candidate: 'std::string std::__cxx11::to_string(unsigned int)'
6660 | to_string(unsigned __val)
| ^~~~~~~~~
/Programs/SDK/gcc/include/c++/11.1.0/bits/basic_string.h:6668:3: note: candidate: 'std::string std::__cxx11::to_string(long int)'
6668 | to_string(long __val)
| ^~~~~~~~~
/Programs/SDK/gcc/include/c++/11.1.0/bits/basic_string.h:6679:3: note: candidate: 'std::string std::__cxx11::to_string(long unsigned int)'
6679 | to_string(unsigned long __val)
| ^~~~~~~~~
/Programs/SDK/gcc/include/c++/11.1.0/bits/basic_string.h:6687:3: note: candidate: 'std::string std::__cxx11::to_string(long long int)'
6687 | to_string(long long __val)
| ^~~~~~~~~
/Programs/SDK/gcc/include/c++/11.1.0/bits/basic_string.h:6699:3: note: candidate: 'std::string std::__cxx11::to_string(long long unsigned int)'
6699 | to_string(unsigned long long __val)
| ^~~~~~~~~
g++ --version
g++ (adtools build 11.1.0) 11.1.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
It's a fine suggestion. Believe me, I prefer C, and could also use it here. But the question really is specific. I am wondering why it is not there for our native GCC11 compiler.
I had the same problem with std::to_string(int) and IIRC the solution to the problem was to compile with -std=gnu++14 instead of -std=c++14.
But then (again IIRC) the solution only worked for either OS3 or OS4 so I had to use the std::stringstream workaround that someone posted in this thread. I don't have access to my development system at the moment so I can't check.
But try -std=gnu++14 or -std=gnu++11 and see if that helps.
Just tested beta version of upcoming SDK - there all builds fine with newlib. With clib2 it ask for "wchar.h" include, which seems clib2 included with SDK does not have , and there will be needs to use Afxgroup's one, if that will be need it.
Do we have a repository of test cases for c++11 features? If this is happening for one of the new library c++11 then it may be happening for others too.
Do we have a repository of test cases for c++11 features? If this is happening for one of the new library c++11 then it may be happening for others too.
Not sure that we have exactly "repo with test cases for c++11" but all the problem about GCC/Binutils and Clib2 we post there:
How can I become a beta tester? Really so that I can report on bugzilla.
if it was that easy when one want to report one or another bug and they let you join in beta-team because of that.
Hyperion full of betatesters already (and always was) and there even no managment anymore as far as i can tell. You may probabaly try to write to Ben but don't hold your hope there. it was always a big pain to join in.
@rjd324 As much as I know there is no opening right now for beta testers. If there is something that doesn't work with newlib I would suggest contacting kas1e or me and we will bring that to developers' attention.
We will only need a good description of the problem and an example code that make the issue reproducable.