From 861e3c5ae936cf6af48d3d80afe61b8a8122d6aa Mon Sep 17 00:00:00 2001 From: Tim Martin <38798827+tmartin-gh@users.noreply.github.com> Date: Thu, 16 Mar 2023 17:08:53 -0700 Subject: [PATCH 1/2] Fix for nvcc warning #170-D: pointer points outside of underlying object --- fmtlog-inl.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/fmtlog-inl.h b/fmtlog-inl.h index f02cab6..dcdc114 100644 --- a/fmtlog-inl.h +++ b/fmtlog-inl.h @@ -68,15 +68,15 @@ class fmtlogDetailT num /= 10; } switch (Size & -2) { - case 18: *(uint16_t*)(s + 16) = *(uint16_t*)(digit_pairs + ((num % 100) << 1)); num /= 100; - case 16: *(uint16_t*)(s + 14) = *(uint16_t*)(digit_pairs + ((num % 100) << 1)); num /= 100; - case 14: *(uint16_t*)(s + 12) = *(uint16_t*)(digit_pairs + ((num % 100) << 1)); num /= 100; - case 12: *(uint16_t*)(s + 10) = *(uint16_t*)(digit_pairs + ((num % 100) << 1)); num /= 100; - case 10: *(uint16_t*)(s + 8) = *(uint16_t*)(digit_pairs + ((num % 100) << 1)); num /= 100; - case 8: *(uint16_t*)(s + 6) = *(uint16_t*)(digit_pairs + ((num % 100) << 1)); num /= 100; - case 6: *(uint16_t*)(s + 4) = *(uint16_t*)(digit_pairs + ((num % 100) << 1)); num /= 100; - case 4: *(uint16_t*)(s + 2) = *(uint16_t*)(digit_pairs + ((num % 100) << 1)); num /= 100; - case 2: *(uint16_t*)(s + 0) = *(uint16_t*)(digit_pairs + ((num % 100) << 1)); num /= 100; + case 18: if constexpr (SIZE > 16) {*(uint16_t*)(s + 16) = *(uint16_t*)(digit_pairs + ((num % 100) << 1)); num /= 100;} + case 16: if constexpr (SIZE > 14) {*(uint16_t*)(s + 14) = *(uint16_t*)(digit_pairs + ((num % 100) << 1)); num /= 100;} + case 14: if constexpr (SIZE > 12) {*(uint16_t*)(s + 12) = *(uint16_t*)(digit_pairs + ((num % 100) << 1)); num /= 100;} + case 12: if constexpr (SIZE > 10) {*(uint16_t*)(s + 10) = *(uint16_t*)(digit_pairs + ((num % 100) << 1)); num /= 100;} + case 10: if constexpr (SIZE > 8) {*(uint16_t*)(s + 8) = *(uint16_t*)(digit_pairs + ((num % 100) << 1)); num /= 100;} + case 8: if constexpr (SIZE > 6) {*(uint16_t*)(s + 6) = *(uint16_t*)(digit_pairs + ((num % 100) << 1)); num /= 100;} + case 6: if constexpr (SIZE > 4) {*(uint16_t*)(s + 4) = *(uint16_t*)(digit_pairs + ((num % 100) << 1)); num /= 100;} + case 4: if constexpr (SIZE > 2) {*(uint16_t*)(s + 2) = *(uint16_t*)(digit_pairs + ((num % 100) << 1)); num /= 100;} + case 2: if constexpr (SIZE > 0) {*(uint16_t*)(s + 0) = *(uint16_t*)(digit_pairs + ((num % 100) << 1)); num /= 100;} } } From 7232e4f9dbc365b1e2c4bd2b31ff17e5bd4c2552 Mon Sep 17 00:00:00 2001 From: Tim Martin <38798827+tmartin-gh@users.noreply.github.com> Date: Thu, 16 Mar 2023 17:10:08 -0700 Subject: [PATCH 2/2] Fix for nvcc warning #186-D: pointless comparison of unsigned integer with zero --- fmtlog.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fmtlog.h b/fmtlog.h index 34674de..0c54b5e 100644 --- a/fmtlog.h +++ b/fmtlog.h @@ -640,7 +640,7 @@ class fmtlogT } fmt::string_view name(begin, p - begin); int id = -1; - for (size_t i = 0; i < num_named_args; ++i) { + if constexpr (num_named_args > 0) for (size_t i = 0; i < num_named_args; ++i) { if (named_args[i].name == name) { id = named_args[i].id; break;