It just is supposed to return the tail of the list, not destroy the list. But statement

  delete p;
returns the first cell in list L to the free memory, destroying list L.