www.digitalmars.com         C & C++   DMDScript  

D.gnu - The following code bypasses immutabililty with GDC but not DMD

reply "Nicholas Smith" <nmsmith65 gmail.com> writes:
I don't know how to file bug reports but I'm sure this shouldn't 
happen :)
DMD gives an error.

import std.stdio;

void main()
{
	immutable Cat cat = cast(immutable) new Cat(5);
	happyBirthday(cat.age);
	writefln("My 5 year old cat is %s years old!", cat.age);
}

void happyBirthday(ref int i)
{
	i++;
}

class Cat
{
	public int age;

	this(int a)
	{
		this.age = age;
	}
}


Output:
My 5 year old cat is 6 years old!
Apr 11 2013
next sibling parent Manu <turkeyman gmail.com> writes:
--089e011607085b44a304da20c243
Content-Type: text/plain; charset=UTF-8

This is an interesting problem with the ref-is-not-part-of-the-type design.
You can't really have a const(ref) in D, and a ref const(int) is kinda
backwards logic.
I've never understood why ref isn't part of the type... can someone explain
why this is a good thing? It seems to cause all sorts of troublesome
problems... auto ref in templates for one.


On 12 April 2013 10:50, Nicholas Smith <nmsmith65 gmail.com> wrote:

 I don't know how to file bug reports but I'm sure this shouldn't happen :)
 DMD gives an error.

 import std.stdio;

 void main()
 {
         immutable Cat cat = cast(immutable) new Cat(5);
         happyBirthday(cat.age);
         writefln("My 5 year old cat is %s years old!", cat.age);
 }

 void happyBirthday(ref int i)
 {
         i++;
 }

 class Cat
 {
         public int age;

         this(int a)
         {
                 this.age = age;
         }
 }


 Output:
 My 5 year old cat is 6 years old!

--089e011607085b44a304da20c243 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">This is an interesting problem with the ref-is-not-part-of= -the-type design. You can&#39;t really have a const(ref) in D, and a ref co= nst(int) is kinda backwards logic.<div style>I&#39;ve never understood why = ref isn&#39;t part of the type... can someone explain why this is a good th= ing? It seems to cause all sorts of troublesome problems... auto ref in tem= plates for one.</div> </div><div class=3D"gmail_extra"><br><br><div class=3D"gmail_quote">On 12 A= pril 2013 10:50, Nicholas Smith <span dir=3D"ltr">&lt;<a href=3D"mailto:nms= mith65 gmail.com" target=3D"_blank">nmsmith65 gmail.com</a>&gt;</span> wrot= e:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex">I don&#39;t know how to file bug reports but= I&#39;m sure this shouldn&#39;t happen :)<br> DMD gives an error.<br> <br> import std.stdio;<br> <br> void main()<br> {<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 immutable Cat cat =3D cast(immutable) new Cat(5= );<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 happyBirthday(cat.age);<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 writefln(&quot;My 5 year old cat is %s years ol= d!&quot;, cat.age);<br> }<br> <br> void happyBirthday(ref int i)<br> {<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 i++;<br> }<br> <br> class Cat<br> {<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 public int age;<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 this(int a)<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 {<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 this.age =3D age;<b= r> =C2=A0 =C2=A0 =C2=A0 =C2=A0 }<br> }<br> <br> <br> Output:<br> My 5 year old cat is 6 years old!<br> </blockquote></div><br></div> --089e011607085b44a304da20c243--
Apr 11 2013
prev sibling next sibling parent "Iain Buclaw" <ibuclaw ubuntu.com> writes:
On Friday, 12 April 2013 at 00:50:03 UTC, Nicholas Smith wrote:
 I don't know how to file bug reports but I'm sure this 
 shouldn't happen :)
 DMD gives an error.

That's a bug in the frontend, which has since been fixed and merged into gdc. Just how old is your compiler? :)
Apr 11 2013
prev sibling next sibling parent Iain Buclaw <ibuclaw ubuntu.com> writes:
--20cf30334f35d0e61804da242d52
Content-Type: text/plain; charset=ISO-8859-1

On 12 April 2013 01:50, Nicholas Smith <nmsmith65 gmail.com> wrote:

 I don't know how to file bug reports but I'm sure this shouldn't happen :)

Regards -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0'; --20cf30334f35d0e61804da242d52 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On 1= 2 April 2013 01:50, Nicholas Smith <span dir=3D"ltr">&lt;<a href=3D"mailto:= nmsmith65 gmail.com" target=3D"_blank">nmsmith65 gmail.com</a>&gt;</span> w= rote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex">I don&#39;t know how to file bug reports but= I&#39;m sure this shouldn&#39;t happen :)<br> <br> </blockquote></div><br></div><div class=3D"gmail_extra">Real gdc bugs get f= iled here:=A0 <a href=3D"http://bugzilla.gdcproject.org">http://bugzilla.gd= cproject.org</a><br><br><br clear=3D"all"></div><div class=3D"gmail_extra">= Regards<br> </div><div class=3D"gmail_extra">-- <br>Iain Buclaw<br><br>*(p &lt; e ? p++= : p) =3D (c &amp; 0x0f) + &#39;0&#39;; </div></div> --20cf30334f35d0e61804da242d52--
Apr 11 2013
prev sibling next sibling parent "Nicholas Smith" <nmsmith65 gmail.com> writes:
On Friday, 12 April 2013 at 06:39:04 UTC, Iain Buclaw wrote:
 On Friday, 12 April 2013 at 00:50:03 UTC, Nicholas Smith wrote:
 I don't know how to file bug reports but I'm sure this 
 shouldn't happen :)
 DMD gives an error.

That's a bug in the frontend, which has since been fixed and merged into gdc. Just how old is your compiler? :)

It's from the Ubuntu Software Centre, apparently version 4.6.3. Not sure how old that is (latest is around 4.8 right?), but I don't have the latest build. I haven't bothered to keep that up to date :) If it's fixed in the current version then hooray.
Apr 12 2013
prev sibling next sibling parent "John Colvin" <john.loughran.colvin gmail.com> writes:
On Friday, 12 April 2013 at 07:53:13 UTC, Nicholas Smith wrote:
 On Friday, 12 April 2013 at 06:39:04 UTC, Iain Buclaw wrote:
 On Friday, 12 April 2013 at 00:50:03 UTC, Nicholas Smith wrote:
 I don't know how to file bug reports but I'm sure this 
 shouldn't happen :)
 DMD gives an error.

That's a bug in the frontend, which has since been fixed and merged into gdc. Just how old is your compiler? :)

It's from the Ubuntu Software Centre, apparently version 4.6.3. Not sure how old that is (latest is around 4.8 right?), but I don't have the latest build. I haven't bothered to keep that up to date :) If it's fixed in the current version then hooray.

IIRC, in GDC time, you're in the distant past.
Apr 12 2013
prev sibling next sibling parent Iain Buclaw <ibuclaw ubuntu.com> writes:
--047d7bf164e48d605f04da27046a
Content-Type: text/plain; charset=ISO-8859-1

On 12 April 2013 10:56, John Colvin <john.loughran.colvin gmail.com> wrote:

 On Friday, 12 April 2013 at 07:53:13 UTC, Nicholas Smith wrote:

 On Friday, 12 April 2013 at 06:39:04 UTC, Iain Buclaw wrote:

 On Friday, 12 April 2013 at 00:50:03 UTC, Nicholas Smith wrote:

 I don't know how to file bug reports but I'm sure this shouldn't happen
 :)
 DMD gives an error.

gdc. Just how old is your compiler? :)

It's from the Ubuntu Software Centre, apparently version 4.6.3. Not sure how old that is (latest is around 4.8 right?), but I don't have the latest build. I haven't bothered to keep that up to date :) If it's fixed in the current version then hooray.

IIRC, in GDC time, you're in the distant past.

In D time, you're a Neanderthal. -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0'; --047d7bf164e48d605f04da27046a Content-Type: text/html; charset=ISO-8859-1 <div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 12 April 2013 10:56, John Colvin <span dir="ltr">&lt;<a href="mailto:john.loughran.colvin gmail.com" target="_blank">john.loughran.colvin gmail.com</a>&gt;</span> wrote:<br> <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Friday, 12 April 2013 at 07:53:13 UTC, Nicholas Smith wrote:<br> <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> On Friday, 12 April 2013 at 06:39:04 UTC, Iain Buclaw wrote:<br> <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> On Friday, 12 April 2013 at 00:50:03 UTC, Nicholas Smith wrote:<br> <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> I don&#39;t know how to file bug reports but I&#39;m sure this shouldn&#39;t happen :)<br> DMD gives an error.<br> <br> </blockquote> <br> That&#39;s a bug in the frontend, which has since been fixed and merged into gdc.<br> <br> Just how old is your compiler? :)<br> </blockquote> <br> It&#39;s from the Ubuntu Software Centre, apparently version 4.6.3.<br> Not sure how old that is (latest is around 4.8 right?), but I don&#39;t have the latest build. I haven&#39;t bothered to keep that up to date :)<br> <br> If it&#39;s fixed in the current version then hooray.<br> </blockquote> <br></div></div> IIRC, in GDC time, you&#39;re in the distant past.<br> </blockquote></div><br></div><div class="gmail_extra">In D time, you&#39;re a Neanderthal. <br clear="all"></div><div class="gmail_extra"><br>-- <br>Iain Buclaw<br><br>*(p &lt; e ? p++ : p) = (c &amp; 0x0f) + &#39;0&#39;; </div></div> --047d7bf164e48d605f04da27046a--
Apr 12 2013
prev sibling next sibling parent "Nicholas Smith" <nmsmith65 gmail.com> writes:
On Friday, 12 April 2013 at 10:03:50 UTC, Iain Buclaw wrote:
 In D time, you're a Neanderthal.

I suppose someone should update that package in the Software Centre then :P Eh, doesn't matter. Looks like I'll have to get my hands dirty if I want to use GDC.
Apr 12 2013
prev sibling next sibling parent Iain Buclaw <ibuclaw ubuntu.com> writes:
--001a11c287fe5a584f04da2863a2
Content-Type: text/plain; charset=ISO-8859-1

On 12 April 2013 12:35, Nicholas Smith <nmsmith65 gmail.com> wrote:

 On Friday, 12 April 2013 at 10:03:50 UTC, Iain Buclaw wrote:

 In D time, you're a Neanderthal.

I suppose someone should update that package in the Software Centre then :P Eh, doesn't matter. Looks like I'll have to get my hands dirty if I want to use GDC.

Package is in process. Expected landing is in the next ubuntu release. -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0'; --001a11c287fe5a584f04da2863a2 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On 1= 2 April 2013 12:35, Nicholas Smith <span dir=3D"ltr">&lt;<a href=3D"mailto:= nmsmith65 gmail.com" target=3D"_blank">nmsmith65 gmail.com</a>&gt;</span> w= rote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"><div class=3D"im">On Friday, 12 April 2013 a= t 10:03:50 UTC, Iain Buclaw wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> In D time, you&#39;re a Neanderthal.<br> </blockquote> <br></div> I suppose someone should update that package in the Software Centre then :P= <br> Eh, doesn&#39;t matter. Looks like I&#39;ll have to get my hands dirty if I= want to use GDC.<br> </blockquote></div><br></div><div class=3D"gmail_extra">Package is in proce= ss.=A0 Expected landing is in the next ubuntu release.<br></div><div class= =3D"gmail_extra"><br clear=3D"all"><br>-- <br>Iain Buclaw<br><br>*(p &lt; e= ? p++ : p) =3D (c &amp; 0x0f) + &#39;0&#39;; </div></div> --001a11c287fe5a584f04da2863a2--
Apr 12 2013
prev sibling parent Joseph Rushton Wakeling <joseph.wakeling webdrake.net> writes:
On 04/12/2013 01:35 PM, Nicholas Smith wrote:
 I suppose someone should update that package in the Software Centre then :P
 Eh, doesn't matter. Looks like I'll have to get my hands dirty if I want to use
 GDC.

It's not too bad to build GDC on Ubuntu once you get the hang of it -- here's my technique using the gcc-snapshot package to get GCC sources: http://forum.dlang.org/thread/mailman.1605.1352199912.5162.d.gnu puremagic.com Note that that post has one small typo in it -- the line that is given as ./setup-gcc.sh ../gcc-snapshot-20121008 should be, ./setup-gcc.sh ../gcc-snapshot-20121008/src Also, note that the gcc-snapshot package has updated since then -- the current with Ubuntu 13.04 is gcc-snapshot-20130330. Finally, the ./configure options listed there are far too extensive. These days, I use simply: ../gcc-snapshot-YYYYmmdd/src/configure --enable-languages=d --disable-multilib --enable-checking=release --prefix=/opt/gdc These days I'm building off the gdc-4.8 branch rather than GDC master, but that may be over-cautious.
Apr 15 2013