Thread overview
[Segfaulting BUG] typedefing function pointers
Feb 09, 2004
Lars Ivar Igesund
Feb 09, 2004
Lars Ivar Igesund
Feb 09, 2004
Sam McCall
Feb 10, 2004
Lars Ivar Igesund
Feb 10, 2004
Andy Friesen
Feb 10, 2004
Lars Ivar Igesund
February 09, 2004
The following code crash dmd with no error message:

<--------------------

int function() foo;
typedef foo bar;

<--------------------

I suppose it isn't allowed to typedef function pointers,
but still, an error message would be nice :)

Lars Ivar Igesund
February 09, 2004
Another one in a similar vein. The following code crash
dmd with no error message:

<----------------------

int function() foo;
int bar(foo fp);

<----------------------

I believe that function pointers as function parameters
are allowed.

Lars Ivar Igesund


Lars Ivar Igesund wrote:

> The following code crash dmd with no error message:
> 
> <--------------------
> 
> int function() foo;
> typedef foo bar;
> 
> <--------------------
> 
> I suppose it isn't allowed to typedef function pointers,
> but still, an error message would be nice :)
> 
> Lars Ivar Igesund
February 09, 2004
Lars Ivar Igesund wrote:
> Another one in a similar vein. The following code crash
> dmd with no error message:
> 
> <----------------------
> 
> int function() foo;
> int bar(foo fp);
> 
> <----------------------
> 
> I believe that function pointers as function parameters
> are allowed.
But isn't foo a variable not a type?
Should error anyway.
Sam
February 10, 2004
Lars Ivar Igesund wrote:

> The following code crash dmd with no error message:
> 
> <--------------------
> 
> int function() foo;
> typedef foo bar;
> 
> <--------------------
> 
> I suppose it isn't allowed to typedef function pointers,
> but still, an error message would be nice :)

the expression 'int function() foo;' doesn't declare a type.  It creates a global called foo, which is a pointer to a function that accepts no arguments, and returns an int.

'typedef foo bar;' on the next line is therefore complete nonsense.

What you probably want is

    typedef int function() bar;

Regardless, it shouldn't segfault the compiler. :)

 -- andy
February 10, 2004
Sam McCall wrote:

> Lars Ivar Igesund wrote:
> 
>> Another one in a similar vein. The following code crash
>> dmd with no error message:
>>
>> <----------------------
>>
>> int function() foo;
>> int bar(foo fp);
>>
>> <----------------------
>>
>> I believe that function pointers as function parameters
>> are allowed.
> 
> But isn't foo a variable not a type?
> Should error anyway.
> Sam


You're right of course. My fault. But it shouldn't segfault.

Lars Ivar Igesund
February 10, 2004
Andy Friesen wrote:

> Lars Ivar Igesund wrote:
> 
>> The following code crash dmd with no error message:
>>
>> <--------------------
>>
>> int function() foo;
>> typedef foo bar;
>>
>> <--------------------
>>
>> I suppose it isn't allowed to typedef function pointers,
>> but still, an error message would be nice :)
> 
> 
> the expression 'int function() foo;' doesn't declare a type.  It creates a global called foo, which is a pointer to a function that accepts no arguments, and returns an int.
> 
> 'typedef foo bar;' on the next line is therefore complete nonsense.
> 
> What you probably want is
> 
>     typedef int function() bar;
> 
> Regardless, it shouldn't segfault the compiler. :)
> 
>  -- andy

You're right of course. My fault. But it shouldn't segfault anyway.

Lars Ivar Igesund