The issue is that the types do not match, and thus you cannot create a reference.
int b = 3;
int* ptr = &b;
int*& ptr_ref = ptr;
Is legal.
int b = 3;
const int* ptr = &b;
const int*& ptr_ref = ptr;
Is legal.
int b = 3;
int* ptr = &b;
const int*& ptr_ref = ptr;
Is a mismatch.
G++'s error message might be helpful to you:
error: invalid initialization of non-const reference of type 'const int*&' from an rvalue of type 'const int*'
const int*& ptr_ref = ptr;
^
Essentially meaning, it had to create a const int*
for this expression, which is an rvalue (essentially a temporary object), and thus you cannot hold a reference to it. A simpler way to put that is, you cannot do what you wrote for the same reason this is illegal:
int& added = 3 + 2;
Depending on your situation, you might solve this simply by removing the reference designation. Most compilers will output identical assembly with or without it, at least when optimized, due to their ability to figure out the fact your variable name is just an alias.
There are even some cases references can perform worse, which depending on your intent, might be worth knowing - I was surprised to know it when I found out.