Description of problem:
Overloads of std::stoi and related functions for std::string are not available when compiling with -m32 leading to errors when the compiler tries to use the std::wstring overload instead.
Version-Release number of selected component (if applicable):
gcc-13.2.1-4.fc39.x86_64
Steps to Reproduce:
Use "g++ -m32 -c test.cpp" to compile this test case:
#include <string>
int foo( std::string s )
{
return std::stoi( s );
}
Actual results:
test.cpp: In function ‘int foo(std::string)’:
test.cpp:5:23: error: invalid initialization of reference of type ‘const std::wstring&’ {aka ‘const std::__cxx11::basic_string<wchar_t>&’} from expression of type ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’}
5 | return std::stoi( s );
| ^
In file included from /usr/include/c++/13/string:54,
from test.cpp:1:
/usr/include/c++/13/bits/basic_string.h:4260:23: note: in passing argument 1 of ‘int std::__cxx11::stoi(const std::wstring&, std::size_t*, int)’
4260 | stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
| ~~~~~~~~~~~~~~~^~~~~
Expected results:
Code compiles.
Additional info:
This works with -m64 as expected - the problem appears to be that /usr/include/c++/13/x86_64-redhat-linux/32/bits/c++config.h defines _GLIBCXX11_USE_C99_STDLIB for 64 bit builds but not for 32 bit builds.
Description of problem: Overloads of std::stoi and related functions for std::string are not available when compiling with -m32 leading to errors when the compiler tries to use the std::wstring overload instead. Version-Release number of selected component (if applicable): gcc-13.2.1-4.fc39.x86_64 Steps to Reproduce: Use "g++ -m32 -c test.cpp" to compile this test case: #include <string> int foo( std::string s ) { return std::stoi( s ); } Actual results: test.cpp: In function ‘int foo(std::string)’: test.cpp:5:23: error: invalid initialization of reference of type ‘const std::wstring&’ {aka ‘const std::__cxx11::basic_string<wchar_t>&’} from expression of type ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} 5 | return std::stoi( s ); | ^ In file included from /usr/include/c++/13/string:54, from test.cpp:1: /usr/include/c++/13/bits/basic_string.h:4260:23: note: in passing argument 1 of ‘int std::__cxx11::stoi(const std::wstring&, std::size_t*, int)’ 4260 | stoi(const wstring& __str, size_t* __idx = 0, int __base = 10) | ~~~~~~~~~~~~~~~^~~~~ Expected results: Code compiles. Additional info: This works with -m64 as expected - the problem appears to be that /usr/include/c++/13/x86_64-redhat-linux/32/bits/c++config.h defines _GLIBCXX11_USE_C99_STDLIB for 64 bit builds but not for 32 bit builds.