Skip to content

Fix small issues in preparation for C++20#653

Merged
phdum-a merged 6 commits into
mainfrom
phdum/pre_cpp20
Mar 3, 2026
Merged

Fix small issues in preparation for C++20#653
phdum-a merged 6 commits into
mainfrom
phdum/pre_cpp20

Conversation

@phdum-a

@phdum-a phdum-a commented Feb 27, 2026

Copy link
Copy Markdown
Contributor

GCC 16 will set C++20 at the default and is expected to be released soon. Currently compiling main with C++20 causes compiler failures, due to small issues (changes in how fmt deals with typing, ADL ambiguity). This PR fixes these issues in a way that is compatible with both C++17 and C++20, so that people can compile with both. This PR does not actually enable C++20 or any C++20 simplifications.

@hughcars hughcars left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, one missed to_array that possibly also needs fixing.

Comment thread palace/linalg/rap.cpp
Comment thread palace/utils/prettyprint.hpp
@phdum-a

phdum-a commented Feb 27, 2026

Copy link
Copy Markdown
Contributor Author

Ok, I found one more issues with ADL on format since C++20 now adds std::format. Different compilers include <format> automatically, so it was not showing up on clang on mac for me. I now qualified all format as fmt::format.

@phdum-a phdum-a force-pushed the phdum/pre_cpp20 branch 2 times, most recently from f16cd29 to 59c04ab Compare March 2, 2026 17:56
@Sbozzolo

Sbozzolo commented Mar 3, 2026

Copy link
Copy Markdown
Member

Would it make sense to have one test that compiles with C++20 (to check we stay compliant)?

@phdum-a

phdum-a commented Mar 3, 2026

Copy link
Copy Markdown
Contributor Author

Would it make sense to have one test that compiles with C++20 (to check we stay compliant)?

Yes, probably good to have one test on a modern "reference" compiler if that is easy to do. And we can only do some quick tests, since the compilation is the important part.

Different compilers (clang, gcc) have different ways they deal with language changes (like what standard library headers are included by default), so we really want a full test suite like in #654, but that needs a cleaned up compiler support matrix.

@Sbozzolo

Sbozzolo commented Mar 3, 2026

Copy link
Copy Markdown
Member

I have not tested this, but this might work for the spack.yml:

  build-x64-gcc-c++20:
    needs: filter
    if: needs.filter.outputs.test == 'true'
    runs-on: [self-hosted, x64]
    steps:
      - uses: actions/checkout@v6
      - uses: ./.github/actions/palace-ci
        with:
          toolchain: gcc
          variant: "cxxstd=20"
          run-regression-tests: 'false'

phdum-a added 6 commits March 3, 2026 11:46
- Future proof as fmt will enforce compile time check in c++20
- Causes error in C++20 due to static type enforcement in fmt
- Replace std::back_inserter with fmt::appender as iterator
- Minor printing fixup
- Works with both c++17 and c++20
@Sbozzolo Sbozzolo added the no-long-tests This PR does not require the long tests to be merged label Mar 3, 2026
@phdum-a phdum-a merged commit 5119587 into main Mar 3, 2026
72 checks passed
@phdum-a phdum-a deleted the phdum/pre_cpp20 branch March 3, 2026 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-long-tests This PR does not require the long tests to be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants