Fix sstream_convert for types not constructible from const char*#418
Open
susilehtola wants to merge 1 commit into
Open
Fix sstream_convert for types not constructible from const char*#418susilehtola wants to merge 1 commit into
susilehtola wants to merge 1 commit into
Conversation
The sstream_convert template constructed the destination type via To to(ss.str().c_str()), which only works when To accepts a const char* (e.g. mpf_class). Instantiations with To = double, used in tests/unit/test-core-ints.cc, fail to compile under gcc 16. Dispatch via SFINAE: keep the c_str() construction for types that accept const char*, and use stream extraction (To to; ss >> to;) for all others. Fixes evaleev#417 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Summary
sstream_convert<To>constructs the destination asTo to(ss.str().c_str()), which only compiles whenToaccepts aconst char*(e.g.mpf_class). Instantiations withTo = doublefromtests/unit/test-core-ints.ccfail to compile under gcc 16.c_str()construction for types constructible fromconst char*(preserves the existingmpf_classprecision-via-string path), and use stream extraction (To to; ss >> to;) for everything else (double, etc.).Fixes #417
Test plan
unit_tests-libint2builds with gcc 16 andLIBINT_HAS_MPFR=1libint2/unit/runandlibint2/unit/sho=gaussian/runctest targets pass🤖 Generated with Claude Code