Skip to content

Fix dangling string_view in rfl::internal::get_type_name_str_view - #804

Open
clockblocker wants to merge 1 commit into
munich-data-engineering:mainfrom
clockblocker:fix-get-type-name-str-view
Open

clockblocker wants to merge 1 commit into
munich-data-engineering:mainfrom
clockblocker:fix-get-type-name-str-view

Conversation

@clockblocker

@clockblocker clockblocker commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes a regression introduced in 433795b44 (v0.26.1) where rfl::internal::get_type_name_str_view<T>() returns a std::string_view pointing into the destroyed by-value StringLiteral<N> temporary returned by get_type_name<T>():

// Before (dangles into temporary StringLiteral<N>, fails constant evaluation)
template <class T>
consteval auto get_type_name_str_view() {
  return get_type_name<T>().string_view();
}

Downstream impact

Downstream consumers calling rfl::internal::get_type_name_str_view<T>() directly fail to compile against v0.26.1+—for example, NVIDIA/cuda-quantum in cudaq/lib/Target/Reflection.h L29–L31:

template <typename T>
constexpr std::string_view qualifiedName =
    rfl::internal::get_type_name_str_view<T>();

Verification

  • Before (290bdb24):
    • Clang 23.1.6: error: call to consteval function 'rfl::internal::get_type_name_str_view<...>' is not a constant expression (pointer to subobject of temporary is not a constant expression)
    • GCC 13.4.0: error: 'std::basic_string_view<char>{..., &<anonymous>.rfl::internal::StringLiteral<...>::arr_...}' is not a constant expression
  • After:
    • Standalone strict header checks (-std=c++20 -Wall -Wextra -Wpedantic -Wshadow -Wconversion -Werror) pass on include/rfl/internal/get_type_name.hpp and include/rfl/internal/cpp20/get_type_name.hpp under both clang++ 23.1.6 and g++ 13.4.0.
    • tests/json/test_regression_bugs.cpp (regression.*, 4/4 tests) passes under clang++ 23.1.6 with -fsanitize=address,undefined -fno-sanitize-recover=all and g++ 13.4.0.
    • Relative-include check (code-checks.yaml) passes.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant