-
Notifications
You must be signed in to change notification settings - Fork 349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use wstring as input to stoull to make GCC 10.1.0 happy #429
base: master
Are you sure you want to change the base?
Conversation
Any thoughts on this? |
This is most likely an issue with your environment/installation. The function should be overloaded so both $ g++ test-stoull.cpp -o test-stoull
$ ./test-stoull hello
0
$ g++ -dumpversion
10.1.0 |
Thank you, I had trouble reproducing this too.
…On Wed, May 27, 2020, 23:18 Eddy L O Jansson ***@***.***> wrote:
This most likely an issue with your environment/installation. The function should
be overloaded
<https://en.cppreference.com/w/cpp/string/basic_string/stoul> so both
std::string and std::wstring should work, and in fact, your example code
compiles without error on my machine.
$ g++ test-stoull.cpp -o test-stoull
$ ./test-stoull hello
0
$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/home/me/local/libexec/gcc/x86_64-linux-gnu/10.1.0/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../gcc-10.1.0/configure --enable-languages=c,c++ --prefix=/home/eddy/local/ --program-suffix=-10 --disable-nls --disable-multilib --with-system-zlib --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --with-cpu=native --with-arch=native --with-tune=native --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.1.0 (GCC)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#429 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABDQEJRLZ3RH6DONKOEJUDRTV7SHANCNFSM4NJLLLXA>
.
|
For future reference: adding -D_GLIBCXX_USE_C99_STDLIB fixes the build: diff --git a/CMakeLists.txt b/CMakeLists.txt
index 657949f..fcedbee 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -44,7 +44,7 @@ else()
endif()
if( CMAKE_COMPILER_IS_GNUCXX )
- append_cxx_compiler_flags("-std=c++11 -Wall -Wextra -DNDEBUG" "GCC" CMAKE_CXX_FLAGS)
+ append_cxx_compiler_flags("-std=c++11 -D_GLIBCXX_USE_C99_STDLIB -Wall -Wextra -DNDEBUG" "GCC" CMAKE_CXX_FLAGS)
append_cxx_compiler_flags("-O3 -ffast-math -funroll-loops" "GCC" CMAKE_CXX_OPT_FLAGS)
if ( CODE_COVERAGE )
append_cxx_compiler_flags("-g -fprofile-arcs -ftest-coverage -lgcov" "GCC" CMAKE_CXX_FLAGS) related to gnu c++ default behaviour discussed in, for example, http://freebsd.1045724.x6.nabble.com/base-gcc-and-GLIBCXX-USE-C99-td5781697.html. sdsl-lite built successfuly in a GNU Guix container this way: penguin2:~/tmp/sdsl-lite$ ~/opt/guix-guile3/bin/guix environment -C guix --ad-hoc cmake libdivsufsort [email protected]
cmake .
make
(...)
[100%] Linking CXX static library libsdsl_static.a
make[2]: Leaving directory '/home/wrk/tmp/sdsl-lite'
[100%] Built target sdsl_static
Not sure why the gcc-toolchain defaults to this older behaviour on GNU Guix. |
I ran into a change in GCC behavior in 10.1.0.
Apparently, it's not possible to apply
std::stoull
to a regularstd::string
, and nowstd::wstring
is required.For instance
Compiling with GCC 10.1.0 gives this error:
I get the same error when trying to compile sdsl-lite in this environment.
Changing the
_parse_number
code to usestd::wstring
resolves the issue. It might be less efficient, but I would expect things to work as before without issue. This patch does that within the io code.I would be happy to hear that someone else can reproduce this. I didn't find much about wstring in the GCC release notes, and my environment is kind of funny (guix install).