There are no side effects or undefined behaviour as far as the program is concerned. delete is invoked on a pointer returned by new, invoked only once, and the object is not accessed after that.
If you try to use the variable test after delete , the results would be unpleasant.
There may be terrible side effects on programmers who write this kind of code, though.
A suggestion:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
int main()
{
int* p = newint(100) ;
{
int& test = *p ;
// use test
}
delete p ;
p = nullptr ;
// ...
}