[cfe-dev] Invalid noreturn

Filipe Cabecinhas filcab at gmail.com
Thu Dec 17 14:16:42 PST 2009


I was trying to compile git with clang but it yielded the "function 
declared 'noreturn' should not return" error. Here is a small test case:

[filcab at Farnsworth ~] $ cat a.c
#include <stdio.h>
#include <stdlib.h>

#define NORETURN __attribute__((__noreturn__))
extern void a(void);

static NORETURN void die_builtin(int err)

static NORETURN void (*die_routine)(int i) = die_builtin;

extern NORETURN void die(int err);
void die (int err)

extern NORETURN void aaa(int err);
void aaa(int err)

[filcab at Farnsworth ~] $ clang -c a.c
a.c:20:1: warning: function declared 'noreturn' should not return
1 diagnostic generated.
[filcab at Farnsworth ~] $

Is this supposed to be like this? Or is it a bug? If I call a noreturn 
function pointer, I get the warning. If I call exit(), I don't.
I was expecting both to have the same behaviour.

The code where I saw this had a die() function which received a va_list. 
After calling this die() function, they "called" the macro va_close() 
and this triggered the warning.



More information about the cfe-dev mailing list