This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Function Pointer to main()
- From: Bob Rossi <bob at brasko dot net>
- To: Pedro Henrique <phphpedrohenrique at yahoo dot com dot br>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Fri, 7 Oct 2005 22:25:16 -0400
- Subject: Re: Function Pointer to main()
- References: <4346FE58.8010004@yahoo.com.br>
On Fri, Oct 07, 2005 at 08:01:44PM -0300, Pedro Henrique wrote:
> Hi Everyone,
>
> I was playing with my compiler and so I tried this:
>
> int main (){
> int (*p_func)() = main;
> p_func();
> }
>
> I was trying to perceive more about the details of main function. Could
> someone explain me what the program tries to do? Why
> doesn't the program begin a infinite recursion?
It does go into an infinate loop. Use GDB to follow the execution. BTW,
that program locked up my machine for a good minute until it died.
Bob Rossi