* Function Pointer to main()
@ 2005-10-08 1:42 Pedro Henrique
2005-10-08 2:25 ` Bob Rossi
0 siblings, 1 reply; 2+ messages in thread
From: Pedro Henrique @ 2005-10-08 1:42 UTC (permalink / raw)
To: gcc-help
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?
(forgive me my english)
Brazil,
Pedro Henrique
_______________________________________________________
Promoção Yahoo! Acesso Grátis: a cada hora navegada você acumula cupons e concorre a mais de 500 prêmios! Participe! http://yahoo.fbiz.com.br/
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Function Pointer to main()
2005-10-08 1:42 Function Pointer to main() Pedro Henrique
@ 2005-10-08 2:25 ` Bob Rossi
0 siblings, 0 replies; 2+ messages in thread
From: Bob Rossi @ 2005-10-08 2:25 UTC (permalink / raw)
To: Pedro Henrique; +Cc: gcc-help
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-10-08 2:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-08 1:42 Function Pointer to main() Pedro Henrique
2005-10-08 2:25 ` Bob Rossi
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).