From 0e3d6a142c1209d46d7f9d2568bc9106a8aef109 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Janel?= <67502353+sjanel@users.noreply.github.com> Date: Sun, 26 Nov 2023 07:32:03 +0100 Subject: [PATCH] Fix gcc-12 compilation error (#312) * Fix gcc 12 compiling error * add test for gcc-12 * replace array with vector this is to avoid breaking the API down the line * pin down ubuntu base images these do get updated with with under active development and there are changes which could affect us * skip gtest + set cxx_std to 20 --------- Co-authored-by: Chris Mc --- .github/workflows/targets.yml | 32 +++++++++++++++++++++++++++++++- include/jwt-cpp/base.h | 8 ++++---- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/.github/workflows/targets.yml b/.github/workflows/targets.yml index 01028d769..b30e2a81a 100644 --- a/.github/workflows/targets.yml +++ b/.github/workflows/targets.yml @@ -18,7 +18,7 @@ jobs: name: GCC 4.8 runs-on: ubuntu-latest container: - image: ubuntu:18.04 + image: ubuntu:bionic-20230530 # 18.04 env: CC: /usr/bin/gcc-4.8 CXX: /usr/bin/g++-4.8 @@ -43,3 +43,33 @@ jobs: run: | CC=gcc-4.8 CXX=g++-4.8 cmake . -DTEST:STRING="defaults-enabled" cmake --build . + + gcc-12: + runs-on: ubuntu-latest + container: + image: ubuntu:jammy-20231004 # 22.04 + env: + CC: /usr/bin/gcc-12 + CXX: /usr/bin/g++-12 + steps: + - run: | + apt-get update + apt-get install -y g++-12 wget make libssl-dev + - uses: actions/checkout@v3 + - uses: ./.github/actions/install/cmake + with: + version: "3.26.3" + url: "https://cmake.org/files/v3.26/cmake-3.26.3.tar.gz" + + - name: setup + run: | + mkdir build + cd build + cmake .. + cmake --install . + + - name: test + working-directory: tests/cmake + run: | + CC=gcc-12 CXX=g++-12 cmake . -DCMAKE_CXX_STANDARD=20 -DTEST:STRING="defaults-enabled" + cmake --build . diff --git a/include/jwt-cpp/base.h b/include/jwt-cpp/base.h index 8e6fc311a..fd3ee281b 100644 --- a/include/jwt-cpp/base.h +++ b/include/jwt-cpp/base.h @@ -39,7 +39,7 @@ namespace jwt { return data; } static const std::string& fill() { - static std::string fill{"="}; + static const std::string fill{"="}; return fill; } }; @@ -62,7 +62,7 @@ namespace jwt { return data; } static const std::string& fill() { - static std::string fill{"%3d"}; + static const std::string fill{"%3d"}; return fill; } }; @@ -82,8 +82,8 @@ namespace jwt { 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '_'}}; return data; } - static const std::initializer_list& fill() { - static std::initializer_list fill{"%3D", "%3d"}; + static const std::vector& fill() { + static const std::vector fill{"%3D", "%3d"}; return fill; } };