public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* g++ delete issue
@ 2004-04-06  3:57 Nilmoni Deb
  2004-04-08  2:22 ` Jim Wilson
  0 siblings, 1 reply; 3+ messages in thread
From: Nilmoni Deb @ 2004-04-06  3:57 UTC (permalink / raw)
  To: gcc-bugs

"gcc -v"

Reading specs from /usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.3.1/specs
Configured with: ../configure --prefix=/usr --libdir=/usr/lib 
--with-slibdir=/lib --mandir=/usr/share/man --infodir=/usr/share/info 
--enable-shared --enable-threads=posix --disable-checking 
--enable-long-long --enable-__cxa_atexit 
--enable-languages=c,c++,ada,f77,objc,java,pascal 
--host=i586-mandrake-linux-gnu --with-system-zlib
Thread model: posix
gcc version 3.3.1 (Mandrake Linux 9.2 3.3.1-2mdk)



The following C++ program compiles ok without any warning, when I use 
"g++ -g file.cpp" .

#include <iostream>
using namespace std;
       
int main()
{
    int u=3;
   
    cout << "u = " << u << endl;
   
    delete &u;
   
    return 0;
}

During runtime, the program segmentation faults after printing the value 
of u. The culprit is obviously the "delete" statement.
My concern is that the compiler allows the explicit "delete &u" 
operation even though the variable u is not user allocated. Should
the compiler be expected to give a warning/error message when such a 
statement appears ?

thanks...




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-04-08  3:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-06  3:57 g++ delete issue Nilmoni Deb
2004-04-08  2:22 ` Jim Wilson
2004-04-08  3:42   ` Nilmoni Deb

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).