|
From: <jr...@bi...> - 2014-04-25 03:58:44
|
int sub(void) {
int *p;
{
int x = 123; p = &x;
}
// Although x is out-of-scope according to the language,
// gcc/g++ allocates local variables by subroutine, not by block contour.
// (Allocating by subroutine is faster and smaller.)
// Therefore p still points somewhere into the current frame,
// and memcheck does not complain when de-referencing p.
// In order to elicit a complaint from memcheck, then the compiler
// must allocate and de-allocate by block contour.
return *p;
}
|