but afterbut after delete [] flag, when u try to access flag[i], it is wrong, the compiler should be aware of it
The default libstdc++ operator new and delete use the libc malloc and free.
since it boils down to function call, i guess g++ is not supposed to do such checking.