|
-
March 10th, 2008, 05:59 PM
#1
map<int,int> x; x[0]; // no valgrind warning?
I tried this code snippet + several variations, plus
using gcc 3.3 through 4.2, plus -00 through -03,
and Valgrind just does not throw up an uninitialized
variable warning:
Code:
#include <stdio.h>
#include <map>
int main() {
std::map<int,int> x;
printf("%d\n", x[0]);
}
I even pulled it up in gdb debugger, and nothing
writes to the memory location. I even added
x[0] = 1; at the end to verify the breakpoint worked.
updated: I made a second try and trapped the STL
writing 0 -- guess I botched the first attempt.
Yet, any such access WILL be zero initially! I'm
trying to prove that it will break to a co-worker -- but
I'm not winning so far.
What's going on? I don't see anything in the STL yet
that would guarantee such behavior for POD! Thanks,
Jason
Last edited by xorbe; March 11th, 2008 at 04:25 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|