[cfe-dev] Function pointer variables

Bill Wendling isanbard at gmail.com
Sat Jun 28 13:42:48 PDT 2008


On Jun 28, 2008, at 12:50 PM, Filipe Cabecinhas wrote:

> Hi,
>
> clang blows up with the following program:
> void (*f)(void);
> void (*f)() = 0;
>
>
> But gcc compiles happily. Also, in the draft for the standard ( http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf
>  ), it is said that (section 6.9.1 - Function definitions):
>
> typedef int F(void); //type F is ‘‘function with no parameters
>                       // returning int’’
> // ...
> int g() { /* ... */ } //RIGHT: g has type compatible with F
>
> So I'm assuming it's a bug in clang.
>
> Also, is there a way to make clang just blow up when there's an error
> like this so one can see easilly where it blew up and inspect the
> code? (I'm aware that often it is not there that the mistake is, but
> it's a starting point)
>
Hi Filipe,

Are you running a "Debug" build? If so, then the assertions should be  
on. You can also look at the source code to see where the message is  
being output (each diagnostic has it's own enum name; look at  
Diagnostics.def for them). You can then set a breakpoint at that place  
in the debugger and see what's going on.

-bw





More information about the cfe-dev mailing list