This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: return statement in a function with the naked attribute
- From: Geert Bosch <bosch at gnat dot com>
- To: reed kotler <rkotler at mips dot com>
- Cc: Ian Lance Taylor <iant at google dot com>, <gcc at gcc dot gnu dot org>, <rdsandiford at googlemail dot com>
- Date: Fri, 3 May 2013 00:40:37 -0400
- Subject: Re: return statement in a function with the naked attribute
- References: <5182EC4D dot 4070207 at mips dot com> <CAKOQZ8wgXQfgpu9kv74c2orXMQw-jVczARicMhXMOgQpyaBNpg at mail dot gmail dot com> <5183361A dot 90705 at mips dot com> <CAKOQZ8z3rAkAD369vHu5Nt0ZfQOMPauaxxXc-C8Nnqxy2WbgXg at mail dot gmail dot com> <518339E0 dot 6060608 at mips dot com>
On May 3, 2013, at 00:15, reed kotler <rkotler@mips.com> wrote:
> There was some confusion on the llvm list because some tests were run on targets that did not support the naked attribute.
>
> I think we are thinking now that the return statement should not be emitted unless explicitly requested.
>
> It's not totally clear in the gcc manual so that is why I was asking.
I clearly is an error to have a function that doesn't return.
So, what you really asking is: "What are the semantics of a (naked)
functon that doesn't return?"
I think it would make sense for a compiler to emit a special error-return
(such as abort()) at the end of such a function, with the expectation that
this code usually would be unreachable and optimized away.
I don't think it makes sense to try and define any other semantics
for a funciotn that doesn't explicitly return a value.
-Geert