[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: allocate 2d pointer. is ths a bug ?

From: h
Subject: Re: allocate 2d pointer. is ths a bug ?
Date: Fri, 11 Aug 2006 09:39:48 +0900

Thanks Bernd Strieder !

i've tried like this already.

$ g++ -o test test.cpp -Wall -ansi -pedantic"

 i didn't see any warning.

but, i'm tring use let me known optimizing option "-O2" and i can see 
warning from g++ exactly.
$ g++ -o test test.cpp -Wall -ansi -pedantic -O2"
test.cpp: In function `int main()':
test.cpp:5: warning: 'str' might be used uninitialized in this function
so, cause i could see warning from VC++ 6.0, it has an optimizing option 


godmode2k at

"Bernd Strieder" <> wrote in message 
>h wrote:
>> Thanks Mehturt.
>> but, it works through g++ on Cygwin and GNU/Linux machine without
>> MS-VC++ 6.0 on win32 machine.
>> i know i've attached code are has a problem.
>> okay, i wanna know exactly attached code are why looks working good in
>> g++ only.
>> that's it.
> I cannot reproduce the exact behaviour. The app crashes at different
> places depending on optimization.
> If you compile with optimization and warnings turned on, then g++ will
> tell you something (g++ -O2 -Wall ...). If you want to know exactly
> what happens, you have to use a debugger to look what the values are
> initialized to. Or you have to insert some more output. But don't be
> surprised, if behaviour changes completely, when you do so. This is the
> very nature of undefined behaviour, it can be like a phantom. You have
> done a simple bug and it will bug you for weeks, randomly. This is why
> it is so nice that the compiler can warn you about missing
> initializations.
> I think it is prossible to create both kinds of apps with undefined
> behaviour on all platforms, non-crashing and crashing ones. The
> differences are subtle, and you have to dig deeply into the whole
> runtime system to understand. You need about the expertise a hacker
> uses to break into some application.
> There is no point in looking for the exact cause, that undefined
> behaviour does not result in a crash, just remove the bug and be happy,
> and remember next time you declare a pointer to initialize, and
> remember to turn warnings on next time you compile.
> Bernd Strieder

reply via email to

[Prev in Thread] Current Thread [Next in Thread]