Thread overview
[Issue 3259] New: Dynamic Initialization of Structs fails type check for some cases
Aug 19, 2009
hskwk@inter7.jp
Sep 06, 2009
HOSOKAWA Kenchi
Sep 07, 2009
Don
August 19, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3259

           Summary: Dynamic Initialization of Structs fails type check for
                    some cases
           Product: D
           Version: 2.031
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: hskwk@inter7.jp


struct S {/* containing anything except reference for class or array */}
struct T {/* containing anything */}
class C {}

void main()
{
    //    invalid initialization is accepted
    S a = T();
    S b = 1;

    //    valid error in compile time : dynamic initilizer of struct
    S c = 1.0;    // cannot cast double to S
    S d = new T;
    S e = new C;
    S f = new int[1];

    //    valid error in compile time : assignment
    a = T();
    b = 1;
}

It seems this problem results from implicit cast in the dynamic initialization
of structs.
It is highly severe when both S and T contain only integer type.

In C, any named enum is treated as int.
This problem resembles that.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 06, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3259



--- Comment #1 from HOSOKAWA Kenchi <hskwk@inter7.jp> 2009-09-05 19:20:39 PDT ---
*** Issue 3302 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 07, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3259


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |clugdbug@yahoo.com.au
         Resolution|                            |DUPLICATE


--- Comment #2 from Don <clugdbug@yahoo.com.au> 2009-09-07 01:16:45 PDT ---
This is a duplicate of bug 2702, which already has a patch. I've confirmed that the patch fixes this case and bug 3202. Vote for 2702! I think it's quite serious.

*** This issue has been marked as a duplicate of issue 2702 ***

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