Thread overview
[phobos] phobos commit, revision 2164
Nov 14, 2010
dsource.org
Nov 14, 2010
David Simcha
Nov 14, 2010
Don Clugston
Nov 14, 2010
David Simcha
Nov 14, 2010
Michel Fortin
Nov 14, 2010
Masahiro Nakagawa
November 13, 2010
phobos commit, revision 2164


user: Masahiro Nakagawa

msg:
Added pure, nothrow and @safe to assumeUnique function

http://www.dsource.org/projects/phobos/changeset/2164

November 13, 2010
I feel like this is a huge bug in the spec.  Why is casting to immutable allowed in @safe code?

On 11/13/2010 8:46 PM, dsource.org wrote:
> phobos commit, revision 2164
>
>
> user: Masahiro Nakagawa
>
> msg:
> Added pure, nothrow and @safe to assumeUnique function
>
> http://www.dsource.org/projects/phobos/changeset/2164
>
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
>

November 14, 2010
That's not a bug in the spec. That's a bug in the compiler -- that shouldn't compile. Please change it to @trusted.

On 14 November 2010 02:50, David Simcha <dsimcha at gmail.com> wrote:
> I feel like this is a huge bug in the spec. ?Why is casting to immutable allowed in @safe code?
>
> On 11/13/2010 8:46 PM, dsource.org wrote:
>>
>> phobos commit, revision 2164
>>
>>
>> user: Masahiro Nakagawa
>>
>> msg:
>> Added pure, nothrow and @safe to assumeUnique function
>>
>> http://www.dsource.org/projects/phobos/changeset/2164
>>
>> _______________________________________________
>> phobos mailing list
>> phobos at puremagic.com
>> http://lists.puremagic.com/mailman/listinfo/phobos
>>
>
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
>
November 13, 2010
According to TDPL page 355, there is no such restriction, i.e. the implication is that casting to, but not from, immutable, is allowed in @safe code.  I've been meaning to ask about this for a long time, but this revision reminded me.

On 11/13/2010 8:54 PM, Don Clugston wrote:
> That's not a bug in the spec. That's a bug in the compiler -- that shouldn't compile. Please change it to @trusted.
>
> On 14 November 2010 02:50, David Simcha<dsimcha at gmail.com>  wrote:
>> I feel like this is a huge bug in the spec.  Why is casting to immutable allowed in @safe code?
>>
>> On 11/13/2010 8:46 PM, dsource.org wrote:
>>> phobos commit, revision 2164
>>>
>>>
>>> user: Masahiro Nakagawa
>>>
>>> msg:
>>> Added pure, nothrow and @safe to assumeUnique function
>>>
>>> http://www.dsource.org/projects/phobos/changeset/2164
>>>
>>> _______________________________________________
>>> phobos mailing list
>>> phobos at puremagic.com
>>> http://lists.puremagic.com/mailman/listinfo/phobos
>>>
>> _______________________________________________
>> phobos mailing list
>> phobos at puremagic.com
>> http://lists.puremagic.com/mailman/listinfo/phobos
>>
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
>

November 13, 2010
Le 2010-11-13 ? 20:54, Don Clugston a ?crit :

> That's not a bug in the spec. That's a bug in the compiler -- that shouldn't compile. Please change it to @trusted.

@trusted should make it compile, but that doesn't mean it is appropriate to make assumeUnique @trusted.

A trusted function should safely encapsulate the unsafe state, but assumeUnique is just a shortcut for a cast and it leaks the potentially unsafe state to the caller. There's nothing you can trust in assumeUnique, it's the caller that must be trusted to do the right thing. Thus, the caller should be the one marked @trusted.

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/



November 14, 2010
Did someone report this bug?
I can't find related issue.


On Sun, 14 Nov 2010 10:54:21 +0900, Don Clugston <dclugston at googlemail.com> wrote:

> That's not a bug in the spec. That's a bug in the compiler -- that shouldn't compile. Please change it to @trusted.
>
> On 14 November 2010 02:50, David Simcha <dsimcha at gmail.com> wrote:
>> I feel like this is a huge bug in the spec.  Why is casting to immutable allowed in @safe code?
>>
>> On 11/13/2010 8:46 PM, dsource.org wrote:
>>>
>>> phobos commit, revision 2164
>>>
>>>
>>> user: Masahiro Nakagawa
>>>
>>> msg:
>>> Added pure, nothrow and @safe to assumeUnique function
>>>
>>> http://www.dsource.org/projects/phobos/changeset/2164
>>>
>>> _______________________________________________
>>> phobos mailing list
>>> phobos at puremagic.com
>>> http://lists.puremagic.com/mailman/listinfo/phobos
>>>
>>
>> _______________________________________________
>> phobos mailing list
>> phobos at puremagic.com
>> http://lists.puremagic.com/mailman/listinfo/phobos
>>
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos