www.digitalmars.com         C & C++   DMDScript  

D - [Segfaulting BUG] typedefing function pointers

reply Lars Ivar Igesund <larsivar igesund.net> writes:
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
Feb 09 2004
next sibling parent reply Lars Ivar Igesund <larsivar igesund.net> writes:
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

Feb 09 2004
parent reply Sam McCall <tunah.d tunah.net> writes:
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.

Should error anyway. Sam
Feb 09 2004
parent Lars Ivar Igesund <larsivar igesund.net> writes:
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
Feb 10 2004
prev sibling parent reply Andy Friesen <andy ikagames.com> writes:
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
Feb 09 2004
parent Lars Ivar Igesund <larsivar igesund.net> writes:
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
Feb 10 2004