0

Say for example if Log_t is a struct. struct

Furthermore, pLog is a variable of Log_t pointer type (stores a pointer/address) and it is initialized to NULL. Is pLog initialized to NULL or the structure members that it points to initialized to NULL.

static Log_t *pLog = NULL;

What would happen if such a variable that is initialized to NULL OR before it has been assigned a NON-NULL value is accessed, for example if we try to read from that NULL address, could there be an exception fault since address 0x0000 is usually where special "jump to" addresses are stored? This is a Link to original issue - Details of Exception Fault

newb7777
  • 517
  • 5
  • 22
  • 6
    Dereferencing `NULL` pointer is invoking undefined behavior. Which in turn might show up as an exception. – Eugene Sh. Jul 27 '17 at 18:40
  • 1
    pLog is initialized to `null`. It doesn't point to any structure members because you have not declared or created an instance of the structure. The `structure members it points to` doesn't exist. If you read from `pLog` right now, it will invoke undefined behaviour. – Felix Guo Jul 27 '17 at 18:43
  • `pLog` will be assigned to `NULL` and it will no more point the structure members. If you have a defined structure pointed by `pLog` and then you assign `pLog` as `NULL`, then the `pLog` will no longer point to the address of the defined structure. if you try to read `pLog` after assigning `NULL` then it will have garbage values. – Praful Surve Jul 27 '17 at 18:48

0 Answers0