1

I have a struct that contains two pointers, < head, iterator > both pointers point to another struct - Node.

typedef struct Map_t {

    Node head;
    Node iterator;

} Map_t;

typedef struct Node_t* Node;

struct Node_t {
    MapDataElement Data;
    MapKeyElement Key;

    struct Node_t *next;
};

typedef struct Map_t *Map;

I want to make the iterator pointer point to the same position as head. heres Debbuging before and after runnning the line:

Before line enter image description here

After line enter image description here

As you can see, after running the line, the map->iterator still points to 0x0.. Why is that?

2
  • Could it relate to compiler optimization? Does this happen when you build with no optimization? Does the update occur after a future step? Commented Apr 19, 2012 at 16:49
  • 2
    It appears to not point to NULL (as evidenced by the other values changing), but Eclipse still shows it as NULL. Eclipse bug? Commented Apr 19, 2012 at 16:50

1 Answer 1

2

It appears that the pointer assignment has occurred as evidenced by your second picture, which highlights the changes to the members of map->iterator. I'd imagine the method runs to completion, returning the pointer 0x9918f0.

This leads me to believe that you're not actually experiencing a failure in pointer assignment, but merely a failure in your debugger (Eclipse) displaying an updated value. This could be due to a bug in Eclipse or it could be due to insufficient debugging information available to Eclipse. It is difficult to say with only the example given.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.