Skip to content

Commit 3e4d827

Browse files
Test gcc 4.8.5 in ci (#268)
1 parent 31d74c1 commit 3e4d827

File tree

10 files changed

+68
-34
lines changed

10 files changed

+68
-34
lines changed

.github/workflows/ci.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,36 @@ jobs:
707707
ninja
708708
./unittest
709709
710+
unittest-linux-gcc-4-8-5:
711+
runs-on: ubuntu-24.04
712+
needs: unittest-linux
713+
steps:
714+
- uses: actions/checkout@v4
715+
- name: dependencies
716+
run: |
717+
wget http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-4.8/g++-4.8_4.8.5-4ubuntu8_amd64.deb
718+
wget http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-4.8/libstdc++-4.8-dev_4.8.5-4ubuntu8_amd64.deb
719+
wget http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-4.8/gcc-4.8-base_4.8.5-4ubuntu8_amd64.deb
720+
wget http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-4.8/gcc-4.8_4.8.5-4ubuntu8_amd64.deb
721+
wget http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-4.8/libgcc-4.8-dev_4.8.5-4ubuntu8_amd64.deb
722+
wget http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-4.8/cpp-4.8_4.8.5-4ubuntu8_amd64.deb
723+
wget http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-4.8/libasan0_4.8.5-4ubuntu8_amd64.deb
724+
sudo apt install ./gcc-4.8_4.8.5-4ubuntu8_amd64.deb ./gcc-4.8-base_4.8.5-4ubuntu8_amd64.deb ./libstdc++-4.8-dev_4.8.5-4ubuntu8_amd64.deb ./cpp-4.8_4.8.5-4ubuntu8_amd64.deb ./libgcc-4.8-dev_4.8.5-4ubuntu8_amd64.deb ./libasan0_4.8.5-4ubuntu8_amd64.deb ./g++-4.8_4.8.5-4ubuntu8_amd64.deb
725+
- name: build and test
726+
run: |
727+
mkdir build
728+
cd build
729+
cmake .. \
730+
-GNinja \
731+
-DCMAKE_BUILD_TYPE=Debug \
732+
-DCMAKE_CXX_COMPILER=g++-4.8 \
733+
-DCMAKE_C_COMPILER=gcc-4.8 \
734+
-DCPPTRACE_WERROR_BUILD=On \
735+
-DCPPTRACE_STD_FORMAT=Off \
736+
-DCPPTRACE_BUILD_TESTING=On
737+
ninja
738+
./unittest
739+
710740
unittest-windows-32-bit:
711741
runs-on: windows-2022
712742
needs: unittest-windows

src/utils/string_view.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
CPPTRACE_BEGIN_NAMESPACE
1010
namespace detail {
11+
constexpr std::size_t string_view::npos;
12+
1113
char string_view::operator[](size_t i) const {
1214
ASSERT(i < size());
1315
return ptr[i];
@@ -47,6 +49,8 @@ namespace detail {
4749
return a.size() == b.size() && std::memcmp(a.data(), b.data(), a.size()) == 0;
4850
}
4951

52+
constexpr std::size_t cstring_view::npos;
53+
5054
cstring_view cstring_view::substr(std::size_t pos) const {
5155
ASSERT(pos <= count);
5256
return {ptr + pos, count - pos};

src/utils/string_view.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace detail {
3131
using const_iterator = const char*;
3232
using reverse_iterator = std::reverse_iterator<iterator>;
3333
using const_reverse_iterator = std::reverse_iterator<reverse_iterator>;
34-
static constexpr std::size_t npos = std::string::npos;
34+
CPPTRACE_EXPORT static constexpr std::size_t npos = std::string::npos;
3535

3636
string_view() : ptr(nullptr), count(0) {}
3737
string_view(const char* str) : ptr(str), count(std::strlen(str)) {}
@@ -108,7 +108,7 @@ namespace detail {
108108
using const_iterator = const char*;
109109
using reverse_iterator = std::reverse_iterator<iterator>;
110110
using const_reverse_iterator = std::reverse_iterator<reverse_iterator>;
111-
static constexpr std::size_t npos = string_view::npos;
111+
CPPTRACE_EXPORT static constexpr std::size_t npos = string_view::npos;
112112

113113
cstring_view() : ptr(nullptr), count(0) {}
114114
cstring_view(const char* str) : ptr(str), count(std::strlen(str)) {}

test/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function(test_cpptrace)
9999
unit/lib/prune_symbol.cpp
100100
)
101101

102-
target_compile_features("${CPPTRACE_TEST_NAME}" PRIVATE cxx_std_20)
102+
target_compile_features("${CPPTRACE_TEST_NAME}" PRIVATE cxx_std_11)
103103
target_link_libraries("${CPPTRACE_TEST_NAME}" PRIVATE ${target_name} GTest::gtest_main GTest::gmock_main)
104104
target_compile_definitions("${CPPTRACE_TEST_NAME}" PRIVATE ${CPPTRACE_DEFINE})
105105

@@ -130,7 +130,7 @@ if(NOT CPPTRACE_SKIP_UNIT)
130130
FetchContent_Declare(
131131
googletest
132132
GIT_REPOSITORY "https://github.com/google/googletest.git"
133-
GIT_TAG f8d7d77c06936315286eb55f8de22cd23c188571 # v1.14.0
133+
GIT_TAG 58d77fa8070e8cec2dc1ed015d66b454c8d78850 # v1.12.1, last to support C++11
134134
)
135135
# For Windows: Prevent overriding the parent project's compiler/linker settings
136136
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)

test/unit/tracing/from_current.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include <algorithm>
2-
#include <string_view>
32
#include <string>
43

54
#include <gtest/gtest.h>
@@ -60,7 +59,7 @@ TEST(FromCurrent, Basic) {
6059
} CPPTRACE_CATCH(const std::runtime_error& e) {
6160
does_enter_catch = true;
6261
EXPECT_FALSE(cpptrace::current_exception_was_rethrown());
63-
EXPECT_EQ(e.what(), "foobar"sv);
62+
EXPECT_EQ(e.what(), std::string("foobar"));
6463
const auto& trace = cpptrace::from_current_exception();
6564
ASSERT_GE(trace.frames.size(), 4);
6665
auto it = std::find_if(
@@ -113,7 +112,7 @@ TEST(FromCurrent, CorrectHandler) {
113112
wrong_handler = true;
114113
}
115114
} CPPTRACE_CATCH(const std::exception& e) {
116-
EXPECT_EQ(e.what(), "foobar"sv);
115+
EXPECT_EQ(e.what(), std::string("foobar"));
117116
const auto& trace = cpptrace::from_current_exception();
118117
auto it = std::find_if(
119118
trace.frames.begin(),
@@ -144,7 +143,7 @@ TEST(FromCurrent, RawTrace) {
144143
static volatile int tco_guard = stacktrace_from_current_1(line_numbers);
145144
(void)tco_guard;
146145
} CPPTRACE_CATCH(const std::exception& e) {
147-
EXPECT_EQ(e.what(), "foobar"sv);
146+
EXPECT_EQ(e.what(), std::string("foobar"));
148147
const auto& raw_trace = cpptrace::raw_trace_from_current_exception();
149148
auto trace = raw_trace.resolve();
150149
auto it = std::find_if(

test/unit/tracing/from_current_try_catch.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include <algorithm>
2-
#include <string_view>
32
#include <string>
43

54
#include <gtest/gtest.h>
@@ -54,7 +53,7 @@ TEST(FromCurrentTryCatch, Basic) {
5453
},
5554
[&] (const std::runtime_error& e) {
5655
EXPECT_FALSE(cpptrace::current_exception_was_rethrown());
57-
EXPECT_EQ(e.what(), "foobar"sv);
56+
EXPECT_EQ(e.what(), std::string("foobar"));
5857
const auto& trace = cpptrace::from_current_exception();
5958
ASSERT_GE(trace.frames.size(), 4);
6059
auto it = std::find_if(
@@ -114,7 +113,7 @@ TEST(FromCurrentTryCatch, CorrectHandler) {
114113
FAIL();
115114
},
116115
[&] (const std::runtime_error& e) {
117-
EXPECT_EQ(e.what(), "foobar"sv);
116+
EXPECT_EQ(e.what(), std::string("foobar"));
118117
const auto& trace = cpptrace::from_current_exception();
119118
auto it = std::find_if(
120119
trace.frames.begin(),
@@ -145,7 +144,7 @@ TEST(FromCurrentTryCatch, RawTrace) {
145144
(void)tco_guard;
146145
},
147146
[&] (const std::runtime_error& e) {
148-
EXPECT_EQ(e.what(), "foobar"sv);
147+
EXPECT_EQ(e.what(), std::string("foobar"));
149148
const auto& raw_trace = cpptrace::raw_trace_from_current_exception();
150149
auto trace = raw_trace.resolve();
151150
auto it = std::find_if(

test/unit/tracing/raw_trace.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ TEST(RawTrace, Basic) {
5858
#ifndef _MSC_VER
5959
raw_trace_basic_precise();
6060
#endif
61-
[[maybe_unused]] volatile int x = 0; // prevent raw_trace_basic_precise() above being a jmp
61+
volatile int x = 0; // prevent raw_trace_basic_precise() above being a jmp
62+
(void)x;
6263
}
6364

6465

test/unit/tracing/rethrow.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include <algorithm>
22
#include <exception>
3-
#include <string_view>
43
#include <string>
54

65
#include <gtest/gtest.h>
@@ -96,7 +95,7 @@ TEST(Rethrow, RethrowPreservesTrace) {
9695
(void)tco_guard;
9796
} CPPTRACE_CATCH(const std::runtime_error& e) {
9897
EXPECT_TRUE(cpptrace::current_exception_was_rethrown());
99-
EXPECT_EQ(e.what(), "foobar"sv);
98+
EXPECT_EQ(e.what(), std::string("foobar"));
10099
auto trace = cpptrace::from_current_exception();
101100
ASSERT_GE(trace.frames.size(), 4);
102101
auto it = std::find_if(
@@ -151,7 +150,7 @@ TEST(Rethrow, RethrowTraceCorrect) {
151150
(void)tco_guard;
152151
} CPPTRACE_CATCH(const std::runtime_error& e) {
153152
EXPECT_TRUE(cpptrace::current_exception_was_rethrown());
154-
EXPECT_EQ(e.what(), "foobar"sv);
153+
EXPECT_EQ(e.what(), std::string("foobar"));
155154
auto rethrow_trace = cpptrace::from_current_exception_rethrow();
156155
ASSERT_GE(rethrow_trace.frames.size(), 4);
157156
// reverse to get the last one matching instead of "`stacktrace_from_current_rethrow_2'::`1'::catch$4()" on msvc
@@ -230,7 +229,7 @@ TEST(Rethrow, RethrowDoesntInterfereWithSubsequentTraces) {
230229
stacktrace_from_current_basic_1(line_numbers);
231230
} CPPTRACE_CATCH(const std::runtime_error& e) {
232231
EXPECT_FALSE(cpptrace::current_exception_was_rethrown());
233-
EXPECT_EQ(e.what(), "foobar"sv);
232+
EXPECT_EQ(e.what(), std::string("foobar"));
234233
auto trace = cpptrace::from_current_exception();
235234
ASSERT_GE(trace.frames.size(), 4);
236235
auto it = std::find_if(

test/unit/tracing/traced_exception.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#include <string_view>
21
#include <string>
32

43
#include <gtest/gtest.h>
@@ -48,7 +47,7 @@ TEST(TracedException, Basic) {
4847
line_numbers.insert(line_numbers.begin(), __LINE__ + 1);
4948
stacktrace_traced_object_1(line_numbers);
5049
} catch(cpptrace::exception& e) {
51-
EXPECT_EQ(e.message(), "foobar"sv);
50+
EXPECT_EQ(e.message(), std::string("foobar"));
5251
const auto& trace = e.trace();
5352
ASSERT_GE(trace.frames.size(), 4);
5453
size_t i = 0;

test/unit/tracing/try_catch.cpp

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include <algorithm>
22
#include <exception>
33
#include <stdexcept>
4-
#include <string_view>
54
#include <string>
65

76
#include <gtest/gtest.h>
@@ -30,7 +29,7 @@ namespace {
3029
throw E(std::forward<Args>(args)...);
3130
}
3231

33-
void check_trace(const cpptrace::stacktrace& trace, std::string_view file, int line) {
32+
void check_trace(const cpptrace::stacktrace& trace, std::string file, int line) {
3433
(void)trace;
3534
(void)file;
3635
(void)line;
@@ -45,7 +44,7 @@ namespace {
4544
#endif
4645
}
4746

48-
void check_trace(const cpptrace::stacktrace& trace, std::string_view try_name) {
47+
void check_trace(const cpptrace::stacktrace& trace, std::string try_name) {
4948
EXPECT_NE(
5049
std::find_if(
5150
trace.begin(),
@@ -70,7 +69,7 @@ namespace {
7069
}
7170

7271
TEST(TryCatch, Basic) {
73-
constexpr std::string_view test_name = __func__;
72+
std::string test_name = __func__;
7473
int line = 0;
7574
bool did_catch = false;
7675
cpptrace::try_catch(
@@ -80,7 +79,7 @@ TEST(TryCatch, Basic) {
8079
},
8180
[&] (const std::runtime_error& e) {
8281
did_catch = true;
83-
EXPECT_EQ(e.what(), "foobar"sv);
82+
EXPECT_EQ(e.what(), std::string("foobar"));
8483
check_trace(cpptrace::from_current_exception(), "try_catch.cpp", line);
8584
check_trace(cpptrace::from_current_exception(), test_name);
8685
}
@@ -102,7 +101,7 @@ TEST(TryCatch, NoException) {
102101
}
103102

104103
TEST(TryCatch, Upcast) {
105-
constexpr std::string_view test_name = __func__;
104+
std::string test_name = __func__;
106105
int line = 0;
107106
bool did_catch = false;
108107
cpptrace::try_catch(
@@ -112,7 +111,7 @@ TEST(TryCatch, Upcast) {
112111
},
113112
[&] (const std::exception& e) {
114113
did_catch = true;
115-
EXPECT_EQ(e.what(), "foobar"sv);
114+
EXPECT_EQ(e.what(), std::string("foobar"));
116115
check_trace(cpptrace::from_current_exception(), "try_catch.cpp", line);
117116
check_trace(cpptrace::from_current_exception(), test_name);
118117
}
@@ -158,7 +157,7 @@ TEST(TryCatch, NoMatchingHandler) {
158157
}
159158

160159
TEST(TryCatch, CorrectHandler) {
161-
constexpr std::string_view test_name = __func__;
160+
std::string test_name = __func__;
162161
int line = 0;
163162
bool did_catch = false;
164163
cpptrace::try_catch(
@@ -174,7 +173,7 @@ TEST(TryCatch, CorrectHandler) {
174173
},
175174
[&] (const std::runtime_error& e) {
176175
did_catch = true;
177-
EXPECT_EQ(e.what(), "foobar"sv);
176+
EXPECT_EQ(e.what(), std::string("foobar"));
178177
check_trace(cpptrace::from_current_exception(), "try_catch.cpp", line);
179178
check_trace(cpptrace::from_current_exception(), test_name);
180179
},
@@ -186,7 +185,7 @@ TEST(TryCatch, CorrectHandler) {
186185
}
187186

188187
TEST(TryCatch, BlanketHandler) {
189-
constexpr std::string_view test_name = __func__;
188+
std::string test_name = __func__;
190189
int line = 0;
191190
bool did_catch = false;
192191
cpptrace::try_catch(
@@ -213,7 +212,7 @@ TEST(TryCatch, BlanketHandler) {
213212
}
214213

215214
TEST(TryCatch, CatchOrdering) {
216-
constexpr std::string_view test_name = __func__;
215+
std::string test_name = __func__;
217216
int line = 0;
218217
bool did_catch = false;
219218
cpptrace::try_catch(
@@ -241,8 +240,8 @@ TEST(TryCatch, CatchOrdering) {
241240

242241
namespace {
243242
struct copy_move_tracker {
244-
inline static int copy = 0;
245-
inline static int move = 0;
243+
static int copy;
244+
static int move;
246245
copy_move_tracker() = default;
247246
copy_move_tracker(const copy_move_tracker&) {
248247
copy++;
@@ -263,6 +262,8 @@ namespace {
263262
move = 0;
264263
}
265264
};
265+
int copy_move_tracker::copy = 0;
266+
int copy_move_tracker::move = 0;
266267
}
267268

268269
TEST(TryCatch, Value) {
@@ -315,8 +316,8 @@ TEST(TryCatch, ConstRef) {
315316

316317
namespace {
317318
struct copy_move_tracker_callable {
318-
inline static int copy = 0;
319-
inline static int move = 0;
319+
static int copy;
320+
static int move;
320321
copy_move_tracker_callable() = default;
321322
copy_move_tracker_callable(const copy_move_tracker&) {
322323
copy++;
@@ -338,6 +339,8 @@ namespace {
338339
}
339340
void operator()() const {}
340341
};
342+
int copy_move_tracker_callable::copy;
343+
int copy_move_tracker_callable::move;
341344
}
342345

343346
TEST(TryCatch, LvalueCallable) {

0 commit comments

Comments
 (0)