[Issue 4322] "void initializer has no value" on struct/union members initialized to "void"

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jun 15 14:55:17 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4322


Don <clugdbug at yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug at yahoo.com.au


--- Comment #3 from Don <clugdbug at yahoo.com.au> 2010-06-15 14:55:14 PDT ---
(In reply to comment #1)
> FWIW, removing line 100 in init.c allows simple examples to
> compile and run correctly. Of course I'm not 100% clear on why the
> error message was there in the first place. :)
> 
> diff --git a/trunk/src/init.c b/trunk/src/init.c
> index ed3a091..cf9bc72 100644
> --- a/trunk/src/init.c
> +++ b/trunk/src/init.c
> @@ -97,7 +97,6 @@ Initializer *VoidInitializer::semantic(Scope *sc, Type 
> *t)
> 
>  Expression *VoidInitializer::toExpression()
>  {
> -    error(loc, "void initializer has no value");
>      return new IntegerExp(0);
>  }
> 
> best,
> Graham

That's too general, the error message is important in other places. I think the
correct fix for the bug, is to allow a void initializer to be used inside
another initializer. This might be a bug in the array literal initializers in
mtype.c, which (from memory) creates an array literal by converting the
initializers to expressions. At least in the case where ALL initializers are
void, the final initializer could also be void.
So the test case should be transformed into:
Foo f = void;
But the simplest solution is probably to change all members into default
initializers, if they are a VoidInitializers.
I recommend to put a breakpoint on the error message and find out where it's
being called from.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list