https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70093

--- Comment #12 from sasho648 at gmail dot com ---
I would really love you guys if you actually could implement something like
this:

void fun(int a)
{
        struct {int _[a];} fun();
}

In order to allow functions returning self-managed VLAs. What I'm proposing is
very simple. When a function is declared with the incomplete type 'void' - it
could be re-declared in it's definition scope with a VM type which will
complete it.

This isn't breaking any existing code nor introducing new complex syntax
(current compiler will emit error message for my above example stating
"conflicting types for 'fun'"). But it's providing us with a way for the return
type to access function local variables and so it's extending our possibilities
for writing code.

We can easily define the rules for such function definitions - first the
function re-declaration must be preceding any return statements. Second this
re-declaration syntax will be only valid for inside a 'void' function
definition and nowhere else. So if we have for example:


void fun(int a);

void fun(int a)
{
        struct {int _[a];} fun();
}

The compiler should emit error for conflicting types as the 'fun' declaration
is of type 'void' and it's definition of VM type 'struct {int _[a];}'.

Reply via email to