www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8753] New: Too aggressive expansion for variables which have void initializer

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8753

           Summary: Too aggressive expansion for variables which have void
                    initializer
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: k.hara.pg gmail.com


--- Comment #0 from Kenji Hara <k.hara.pg gmail.com> 2012-10-04 06:14:34 PDT ---
Current dmd aggressively expand const/immutable variables in optimization, but
it reports unuseful errors against void initialized variables.

This code should compile, but doesn't.

void main()
{
    int mx = void;
    const int cx = void;
    immutable int ix = void;
    mx = cx;   // Error: void initializer has no value
    mx = ix;   // Error: void initializer has no value
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 04 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8753



--- Comment #1 from Kenji Hara <k.hara.pg gmail.com> 2012-10-04 06:44:44 PDT ---
Say more accurately, my argue is "such code should be semantically allowed by D
front end". So, even if backend code generation might warn the using of unset
variable, it is not bad behavior.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 04 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8753


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull


--- Comment #2 from Kenji Hara <k.hara.pg gmail.com> 2012-10-04 06:50:18 PDT ---
https://github.com/D-Programming-Language/dmd/pull/1162

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 04 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8753


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID


--- Comment #3 from Kenji Hara <k.hara.pg gmail.com> 2012-10-05 22:00:29 PDT ---
From the discussion in github, I've agreed that this is an invalid issue.

By Don Clugston,
 I am sorry, I'm completely unconvinced by this. If you write: "immutable int
ix = void", there is no way, without breaking the type system, that ix could
ever be given a value. Such code is simply wrong.

 Now we could change the meaning of "= void" to mean, set in a constructor. In
that case, "immutable int ix = void;" and "immutable int ix;" are the same.
Then no constant folding would ever be performed on something with a void
initializer. I think that's a reasonable language change.

 But even in this case, the test code should not compile (it's neither in
module scope, where there could be a static this, nor in an aggregate where
there could be a constructor).
 
 The situation in bug 3449 is an entirely different issue.

Then, const/immutable local variables which initialized with void is meaningless. Such compiler's behavior might not be so bad. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 05 2012