Skip to content

[MRE] cant resolve static variable offset for templated class #629

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Vipul-Cariappa
Copy link
Collaborator

@Vipul-Cariappa Vipul-Cariappa commented Jun 13, 2025

This is a bug report.

template <typename T>
struct ClassWithStatic {
    static T const ref_value;
};
template <typename T>
T constexpr ClassWithStatic<T>::ref_value = 42;

ClassWithStatic<int> x;
Cpp::GetVariableOffset(x.ref_val); // FAILS

Will help fix a test in cppyy.

Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@Vipul-Cariappa Vipul-Cariappa force-pushed the bug/templ-class-static-dm branch from 510222c to aa78f32 Compare June 13, 2025 14:02
Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@Vipul-Cariappa Vipul-Cariappa force-pushed the bug/templ-class-static-dm branch from aa78f32 to 517b64d Compare July 15, 2025 12:43
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

@@ -1492,7 +1492,8 @@ intptr_t GetVariableOffset(compat::Interpreter& I, Decl* D,
#ifdef CPPINTEROP_USE_CLING
cling::Interpreter::PushTransactionRAII RAII(&getInterp());
#endif // CPPINTEROP_USE_CLING
getSema().InstantiateVariableDefinition(SourceLocation(), VD);
getSema().InstantiateVariableDefinition(SourceLocation(), VD, true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "llvm::sys::DynamicLibrary" is directly included [misc-include-cleaner]

lib/CppInterOp/CppInterOp.cpp:40:

- #if CLANG_VERSION_MAJOR >= 19
+ #include <llvm/Support/DynamicLibrary.h>
+ #if CLANG_VERSION_MAJOR >= 19

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