http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52213
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-02-12 13:44:17 UTC --- Please provide *complete* testcases, this code is missing <stdio.h> and <string.h>, since you already wrote it so it compiles why should we have to add headers again to test it? (In reply to comment #0) > <code> > int main(){ > > for (int i = 1; i < 100; i++){ > char* name = new char[i]; the array elements will be uninitialized > for (int j=0; j<i; j++) {name[j] = '1';} > int length = strlen(name); This is undefined behaviour, there is no null terminator in the array, how is strlen supposed to find the length?