Thread overview
The following code bypasses immutabililty with GDC but not DMD
Apr 12, 2013
Nicholas Smith
Apr 12, 2013
Manu
Apr 12, 2013
Iain Buclaw
Apr 12, 2013
Nicholas Smith
Apr 12, 2013
John Colvin
Apr 12, 2013
Iain Buclaw
Apr 12, 2013
Nicholas Smith
Apr 12, 2013
Iain Buclaw
Apr 12, 2013
Iain Buclaw
April 12, 2013
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!
April 12, 2013
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!
>


April 12, 2013
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? :)
April 12, 2013
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 :)
>
>
Real gdc bugs get filed here:  http://bugzilla.gdcproject.org


Regards
-- 
Iain Buclaw

*(p < e ? p++ : p) = (c & 0x0f) + '0';


April 12, 2013
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.
April 12, 2013
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.
April 12, 2013
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.
>>>>
>>>>
>>> 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.
>

In D time, you're a Neanderthal.

-- 
Iain Buclaw

*(p < e ? p++ : p) = (c & 0x0f) + '0';


April 12, 2013
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.
April 12, 2013
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';


April 15, 2013
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.