www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 215] New: static initialization problem - invalid code, bogus error message

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

           Summary: static initialization problem - invalid code, bogus
                    error message
           Product: D
           Version: 0.161
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid, wrong-code
          Severity: critical
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: h3r3tic mat.uni.torun.pl


The folowing code:

// tmp11.d:
template Foo() {
        template nothing(int i = 0) {
        }

        int foo = 1;
}


struct Bar {
        mixin Foo f;
}
// ----

Causes DMD to output the following error:
tmp11.d(9): struct tmp11.Bar overlapping initialization for struct Bar.foo

Yet this is still nothing compared to:

// ----
template Foo() {
        template nothing(int i = 0) {
        }

        struct Blah {
                int foo = 1;
        }

        Blah blah;
}


struct Bar {
        mixin Foo f;
}


void main()
{
        Bar y;
        printf("%d\n", y.f.blah.foo);
        assert (y.f.blah.foo == 1);
}
// ----

Which compiles, and when ran, prints '0' and reports a failed assertion error
:(


-- 
Jun 21 2006
next sibling parent Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

d-bugmail puremagic.com schrieb am 2006-06-21:
 http://d.puremagic.com/issues/show_bug.cgi?id=215

 The folowing code:

 // tmp11.d:
 template Foo() {
         template nothing(int i = 0) {
         }

         int foo = 1;
 }


 struct Bar {
         mixin Foo f;
 }
 // ----

 Causes DMD to output the following error:
 tmp11.d(9): struct tmp11.Bar overlapping initialization for struct Bar.foo

Added to DStress as http://dstress.kuehne.cn/run/t/template_38_A.d http://dstress.kuehne.cn/run/t/template_38_B.d http://dstress.kuehne.cn/run/t/template_38_C.d http://dstress.kuehne.cn/run/t/template_38_D.d
 Yet this is still nothing compared to:

 // ----
 template Foo() {
         template nothing(int i = 0) {
         }

         struct Blah {
                 int foo = 1;
         }

         Blah blah;
 }


 struct Bar {
         mixin Foo f;
 }


 void main()
 {
         Bar y;
         printf("%d\n", y.f.blah.foo);
         assert (y.f.blah.foo == 1);
 }
 // ----

 Which compiles, and when ran, prints '0' and reports a failed assertion error
:(

Added to DStress as http://dstress.kuehne.cn/run/t/template_39_A.d http://dstress.kuehne.cn/run/t/template_39_B.d http://dstress.kuehne.cn/run/t/template_39_C.d http://dstress.kuehne.cn/run/t/template_39_D.d http://dstress.kuehne.cn/run/t/template_39_E.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFErk9CLK5blCcjpWoRAq14AKCNCVe7JyujSum1Vf0/I9nAEfsWQACfdzwe 0FsCLozB3iX4hnpNAV8dFd8= =/SFJ -----END PGP SIGNATURE-----
Jul 07 2006
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=215


deewiant gmail.com changed:

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




------- Comment #1 from deewiant gmail.com  2006-11-15 05:01 -------
Works in DMD 0.174.


-- 
Nov 15 2006