You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] NDK r29: local static referenes returns they address, instead of value #2213
Static references to symbols obtained via dlsym behave unexpectedly in the latest release (29.0.14206865). Instead of returning the value of the variable, reading the static reference appears to return the address.
Steps from my environment
Retrieve symbol pointer:
auto ptr_to_var = dlsym(pLib, "variable_name");
Assign the symbol to a local static reference inside a function:
void foo(){
static auto &variable_name = *reinterpret_cast<int*>(ptr_to_var);
}
Reading the reference returns the address rather than the value:
int foo(){
static auto &variable_name = *reinterpret_cast<int*>(ptr_to_var);
return variable_name; // returns `reinterpret_cast<int>(&variable_name)` instead of value of variable_name
}
Workaround
Passing the reference as an rvalue argument to a function seems to behave correctly:
changed the title [-][BUG] local static referenes returns they address, instead of value[/-][+][BUG] NDK r29: local static referenes returns they address, instead of value[/+]on Nov 20, 2025
Activity
[-][BUG] local static referenes returns they address, instead of value[/-][+][BUG] NDK r29: local static referenes returns they address, instead of value[/+]sr-tream commentedon Nov 20, 2025
The NDK r29 beta 2
29.0.13599879is unaffectedDanAlbert commentedon Nov 21, 2025
Is this not a reference to a temporary that's immediately discarded? This looks like UB to me. @pirama-arumuga-nainar?
sr-tream commentedon Nov 21, 2025
No, it's not a reference to tmp object. It's a reference created from a pointer to a global variable imported from another library
DanAlbert commentedon Nov 21, 2025
It's a reference to the dereferenced value of the global, which I think is a temporary.