[Issue 10950] [CTFE] enum "char[]" not correctly duplicated when used.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Sep 3 06:18:55 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10950



--- Comment #4 from monarchdodra at gmail.com 2013-09-03 06:18:53 PDT ---
(In reply to comment #2)
> I think the "root" issue is that when the enum is first instantiated, the
> compiler doesn't care what the "marked" type of the enum is, but rather, what
> the actual (ctfe) memory points to.
> 
> //----
> module test;
> 
> char[] cc()
> {
>     return cast(char[])"hello";
> }
> 
> string ss()
> {
>     return cast(string)['a', 'b'];
> }
> 
> void main()
> {
>     auto cc1 = cc; //*Should* duplicate
>     auto cc2 = cc; //*Should* duplicate
>     auto ss1 = ss; //Should *not* duplicate
>     auto ss2 = ss; //Should *not* duplicate
>     assert(cc1 !is cc2); //Failed to duplicate
>     assert(ss1  is ss2); //Failed to not duplicate
> }
> //----

Sorry, the example should have been:

enum cc = cast(char[])"hello";
enum ss = cast(string)['a', 'b'];

void main()
{
    auto cc1 = cc; //*Should* duplicate
    auto cc2 = cc; //*Should* duplicate
    auto ss1 = ss; //Should *not* duplicate
    auto ss2 = ss; //Should *not* duplicate
    assert(cc1 !is cc2); //Failed to duplicate
    assert(ss1  is ss2); //Failed to not duplicate
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list