Skip to content

Commit a1a3f7b

Browse files
jll63claude
andcommitted
Fix gcc-12 -Wmicrosoft-cast warning in trace_sink_impl
Explicitly convert function pointer to std::uintptr_t in write_pf() instead of relying on implicit conversion through operator<<. This avoids the -Wmicrosoft-cast warning while using the same reinterpret_cast approach that ostdstream.hpp already uses for function pointer output. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent a0e1c8a commit a1a3f7b

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

include/boost/openmethod/initialize.hpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <boost/openmethod/detail/ostdstream.hpp>
1111

1212
#include <algorithm>
13+
#include <charconv>
1314
#include <cstdint>
1415
#include <deque>
1516
#include <map>
@@ -166,7 +167,14 @@ struct trace_sink_impl : trace_sink {
166167

167168
void write_pf(void (*value)()) override {
168169
if constexpr (Registry::has_output) {
169-
Registry::output::stream() << value;
170+
// Explicit conversion to avoid -Wmicrosoft-cast warning on
171+
// implicit function-pointer to void-pointer conversion
172+
std::array<char, 20> str;
173+
auto end = std::to_chars(
174+
str.data(), str.data() + str.size(),
175+
reinterpret_cast<std::uintptr_t>(value), 16)
176+
.ptr;
177+
Registry::output::stream() << std::string_view(str.data(), end - str.data());
170178
}
171179
}
172180

0 commit comments

Comments
 (0)