[cfe-dev] naked attribute

Rafael EspĂ­ndola rafael.espindola at gmail.com
Mon May 6 08:08:17 PDT 2013

On 3 May 2013 15:55, Reed Kotler <rkotler at mips.com> wrote:
> My original main post was on the idea of not emitting implicit "return"
> statements, and instead to emit implicit "unreachable".
> However if the code contains an explicit "return", clang should honor that.

I tested

__attribute__((naked)) void f1(void) {
__attribute__((naked)) void f2(void) {
__attribute__((naked)) int f3(void) {
__attribute__((naked)) int f4(void) {
  return 42;
void g(void);
__attribute__((naked)) void f5(int a) {
  if (a)

on ARM and gcc only produces return instructions when there is a value
involved (f4). Given that this is fairly insane and documented to not
be safe, I think your proposal is OK. Always producing an unreachable
would also be I think.

Anton, the lack of documentation makes the stronger point for warning,
no? Reed, -allow-naked would be redundant with a -Werror if we do
implement the warning, no?


More information about the cfe-dev mailing list