Prevent the crash by not making the codegen try to access the non-existing ptr field in the slice. Closes #6951