EECS 280 Discussion.week10

EECS 280 - EECS 280 Discussion#10 Memory Issues and Debugging Pointer Initialization What happens if the following code is run int p*p =1 Pointer

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
EECS 280 Discussion #10 Memory Issues and Debugging
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Pointer Initialization What happens if the following code is run: int * p; *p+=1;
Background image of page 2
Pointer Initialization What happens if the following code is run: int * p; *p+=1; BEST CASE: SEGFAULT (?)
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Pointer Initialization What happens if the following code is run: int * p; *p+=1; BEST CASE: SEGFAULT (?) WORSE CASE: UNDEFINED BEHAVIOR
Background image of page 4
Pointer Initialization What happens if the following code is run: int * p = NULL; *p+=1; EVERY CASE: SEG FAULT
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
NEW CONCEPT: SEGFAULTS ARE GOOD Seg faults aren’t generally very fun, but…
Background image of page 6
NEW CONCEPT: SEGFAULTS ARE GOOD Seg faults aren’t generally very fun, but…it is SO MUCH BETTER to have a seg fault early in your code than have an undefined behavior
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
NEW CONCEPT: SEGFAULTS ARE GOOD Seg faults aren’t generally very fun, but…it is SO MUCH BETTER to have a seg fault early in your code than have an undefined behavior Thus: int * p; //BAD int * p = NULL; //BETTER!
Background image of page 8
Whoa… back up… What’s ‘NULL’? ‘NULL’ is defined in <
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/14/2010 for the course EECS 280 taught by Professor Noble during the Fall '08 term at University of Michigan.

Page1 / 20

EECS 280 - EECS 280 Discussion#10 Memory Issues and Debugging Pointer Initialization What happens if the following code is run int p*p =1 Pointer

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online