www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Compile error!

reply "sdv" <sdvcn 126.com> writes:
import std.stdio;
import core.memory;

struct sQueue(T)
{
	struct sNode
	{
		T	mfPayload = T.init;
		union{
			typeof(this)*	mfPrev;
			shared(typeof(this)*)	mfShPrev;
		}
		union{
			typeof(this)*	mfNext;
			shared(typeof(this)*)	mfShNext;
		}
	}


	//shared(sQueueNode)	mfRoot;
	sNode	mfRoot;

	void pfPut(T v,sNode* r = null)
	{
		if(r is null) r = &this.mfRoot;
		shared auto n = new sNode(v);

	}

}


int main(string[] argv)
{
	auto b1 = new sQueue!uint;



     writeln("Hello D-World!");
	writeln("Hello D-World!");
	writeln("Hello D-World!");
     return 0;
}
Jul 31 2015
parent reply "sdv" <sdvcn 126.com> writes:
On Saturday, 1 August 2015 at 04:26:45 UTC, sdv wrote:
 import std.stdio;
 import core.memory;

 struct sQueue(T)
 {
 	struct sNode
 	{
 		T	mfPayload = T.init;
 		union{
 			typeof(this)*	mfPrev;
 			shared(typeof(this)*)	mfShPrev;
 		}
 		union{
 			typeof(this)*	mfNext;
 			shared(typeof(this)*)	mfShNext;
 		}
 	}


 	//shared(sQueueNode)	mfRoot;
 	sNode	mfRoot;

 	void pfPut(T v,sNode* r = null)
 	{
 		if(r is null) r = &this.mfRoot;
 		shared auto n = new sNode(v);

 	}

 }


 int main(string[] argv)
 {
 	auto b1 = new sQueue!uint;



     writeln("Hello D-World!");
 	writeln("Hello D-World!");
 	writeln("Hello D-World!");
     return 0;
 }
DMD32 D Compiler v2.067.1
Jul 31 2015
parent Kenji Hara via Digitalmars-d <digitalmars-d puremagic.com> writes:
2015-08-01 13:27 GMT+09:00 sdv via Digitalmars-d <
digitalmars-d puremagic.com>:

 On Saturday, 1 August 2015 at 04:26:45 UTC, sdv wrote:

 import std.stdio;
 import core.memory;

 struct sQueue(T)
 {
         struct sNode
         {
                 T       mfPayload = T.init;
                 union{
                         typeof(this)*   mfPrev;
                         shared(typeof(this)*)   mfShPrev;
                 }
                 union{
                         typeof(this)*   mfNext;
                         shared(typeof(this)*)   mfShNext;
                 }
         }


         //shared(sQueueNode)    mfRoot;
         sNode   mfRoot;

         void pfPut(T v,sNode* r = null)
         {
                 if(r is null) r = &this.mfRoot;
                 shared auto n = new sNode(v);

         }

 }


 int main(string[] argv)
 {
         auto b1 = new sQueue!uint;



     writeln("Hello D-World!");
         writeln("Hello D-World!");
         writeln("Hello D-World!");
     return 0;
 }
DMD32 D Compiler v2.067.1
Do you mean the dmd segfault when you compile the code? Yes, it's a compiler bug. I filed the issue in bugzilla: https://issues.dlang.org/show_bug.cgi?id=14853 Kenji Hara
Jul 31 2015