use wstring as input to stoull to make GCC 10.1.0 happy - #429
Open
ekg wants to merge 1 commit into
Open
Conversation
Contributor
Author
|
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 |
Contributor
Author
|
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 gcc-toolchain@10.1.0
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I ran into a change in GCC behavior in 10.1.0.
Apparently, it's not possible to apply
std::stoullto a regularstd::string, and nowstd::wstringis 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_numbercode to usestd::wstringresolves 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).