passing an uninitialize pointer

R

Richard Bos

Orhan Kavrakoglu said:
int *pointer1;
foo(&pointer1);

void foo(int **pointer)
{
*pointer = malloc(...);
}

I would say that this does not invoke UB (never mind the memory leak)
because the uninitialized pointer1 is never dereferenced. Am I
correct?

Yup. Moreover, it is never passed _as_ a pointer. Only its address is
passed.

Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,145
Messages
2,570,824
Members
47,370
Latest member
desertedtyro29

Latest Threads

Top