Re: Class hierarchy of exceptions (Ada, C++)
From: Ioannis Vranos (ivr_at_remove.this.grad.com)
Date: 03/30/05
- Next message: Ron Natalie: "Re: _wcsupr () with german characters"
- Previous message: fabio de francesco: "Re: Class hierarchy of exceptions (Ada, C++)"
- In reply to: fabio de francesco: "Re: Class hierarchy of exceptions (Ada, C++)"
- Next in thread: fabio de francesco: "Re: Class hierarchy of exceptions (Ada, C++)"
- Reply: fabio de francesco: "Re: Class hierarchy of exceptions (Ada, C++)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 30 Mar 2005 16:07:13 +0300
fabio de francesco wrote:
> Is the following permitted in C++?
>
> // file point.cpp
>
> #include <iostream>
>
> int *p = 0;
>
> void fun()
> {
> int a = 1;
> p = &a;
> }
>
> int main()
> {
> fun();
> ++(*p);
> std::cout << *p << '\n';
> return 0;
> }
>
> My compiler (GCC-3.4.1) doesn't raise any error with "g++ point.cpp
> -Wall -W".
>
> Shouldn't it have to complain?
It is permitted. What you are incrementing above is the value stored in variable a.
Also check this:
#include <iostream>
#include <cstdlib>
#include <csignal>
inline void SigSegVHandler(int signal)
{
using namespace std;
cerr<<"Illegal memory operation!\n"<<"Exiting...\n";
exit(EXIT_FAILURE);
}
int main()
{
using namespace std;
signal(SIGSEGV, SigSegVHandler);
int *p= 0;
++(*p);
return 0;
}
-- Ioannis Vranos http://www23.brinkster.com/noicys
- Next message: Ron Natalie: "Re: _wcsupr () with german characters"
- Previous message: fabio de francesco: "Re: Class hierarchy of exceptions (Ada, C++)"
- In reply to: fabio de francesco: "Re: Class hierarchy of exceptions (Ada, C++)"
- Next in thread: fabio de francesco: "Re: Class hierarchy of exceptions (Ada, C++)"
- Reply: fabio de francesco: "Re: Class hierarchy of exceptions (Ada, C++)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|