Skip to content

Commit 3040cd4

Browse files
Pierre-Luc GagnéCopilot
andcommitted
fix: resolve Clang-20 and MSVC compilation errors
column_field.hpp (Clang-20): - Replace captureless lambda in tag_to_column_name consteval function with a ternary expression. Clang-20 correctly rejects references to local constexpr variables inside a [] lambda; GCC was permissive. Ternary preserves identical min-of-two-finds logic without any capture. test_dql_extensions.cpp (MSVC): - Qualify ds_mysql::round and ds_mysql::format with explicit namespace in the round/format alias test (line 297). MSVC pulls ::round from <cmath> into the global namespace, making unqualified 'round' ambiguous when 'using namespace ds_mysql' is also active. ci.yml (Clang job): - Use clang-20 instead of clang-18. clang-18 has a known bug where __is_base_of returns false for column_field<Tag,T> derived from column_field_tag via a base<T> partial specialization; clang-20 is correct. Ubuntu noble 24.04 ships clang-20 in its standard repos. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ae9cf7d commit 3040cd4

3 files changed

Lines changed: 9 additions & 14 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@ jobs:
8989
echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ noble main' \
9090
| sudo tee /etc/apt/sources.list.d/kitware.list
9191
sudo apt-get update -q
92-
sudo apt-get install -y cmake ninja-build clang-18 \
92+
sudo apt-get install -y cmake ninja-build clang-20 \
9393
libmysqlclient-dev pkg-config
9494
9595
- name: Configure
9696
run: cmake --preset release -DSKIP_DOCKER_MANAGEMENT=ON -DBUILD_INTEGRATION_TESTS=OFF -DBUILD_EXAMPLES=OFF
9797
env:
98-
CXX: clang++-18
99-
CC: clang-18
98+
CXX: clang++-20
99+
CC: clang-20
100100

101101
- name: Build
102102
run: cmake --build build -j4

lib/include/ds_mysql/column_field.hpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,9 @@ consteval std::string_view tag_to_column_name() noexcept {
6363
constexpr auto start = key_pos + key.size();
6464
constexpr auto end1 = sig.find(';', start);
6565
constexpr auto end2 = sig.find(']', start);
66-
constexpr auto end = [] {
67-
if constexpr (end1 != npos && end2 != npos) {
68-
return (end1 < end2) ? end1 : end2;
69-
} else if constexpr (end1 != npos) {
70-
return end1;
71-
} else if constexpr (end2 != npos) {
72-
return end2;
73-
}
74-
return npos;
75-
}();
66+
constexpr auto end = (end1 != npos && end2 != npos) ? ((end1 < end2) ? end1 : end2) :
67+
(end1 != npos) ? end1 :
68+
(end2 != npos) ? end2 : npos;
7669
if constexpr (end == npos || end <= start) {
7770
static_assert(dependent_false_v<Tag>, "Failed to locate end of Tag name in compiler function signature");
7871
return {};

tests/unit/test_dql_extensions.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,9 @@ suite<"DQL Scalar Functions"> dql_scalar_functions_suite = [] {
294294

295295
"round/format aliases — generate expected SQL"_test = [] {
296296
auto const sql =
297-
select<round<product::price_val, 2>, format<product::price_val, 2>>().from<product>().build_sql();
297+
select<ds_mysql::round<product::price_val, 2>, ds_mysql::format<product::price_val, 2>>()
298+
.from<product>()
299+
.build_sql();
298300
expect(sql == "SELECT ROUND(price_val, 2), FORMAT(price_val, 2) FROM product"s) << sql;
299301
};
300302

0 commit comments

Comments
 (0)