www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6571] New: typedefs ignore const, shared, immutable etc modifiers when implicitly converting

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6571

           Summary: typedefs ignore const, shared, immutable etc modifiers
                    when implicitly converting
           Product: D
           Version: D1
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: yebblies gmail.com



The following compiles without error on dmd2.055 head, although it includes
casting shared(void*) to void* and const(void*) to void*.  alias doesn't not
have the same problems.

void main()
{   
    typedef void* A;
    void AA(A a) {}
    shared A a;
    const A b;
    AA(a);
    AA(b);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 29 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6571


Iain Buclaw <ibuclaw ubuntu.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ibuclaw ubuntu.com



I think this should sort it:


 MATCH TypeTypedef::constConv(Type *to)
 {
     if (equals(to))
         return MATCHexact;
-    if (ty == to->ty && sym == ((TypeTypedef *)to)->sym)
-        return sym->basetype->implicitConvTo(((TypeTypedef
*)to)->sym->basetype);
+    if (ty == to->ty && sym == ((TypeTypedef *)to)->sym &&
+        MODimplicitConv(mod, to->mod))
+        return MATCHconst;
     return MATCHnomatch;
 }



Regards

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 29 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6571




Patch breaks std.encoding:

std/encoding.d:373: Error: cannot implicitly convert expression (s[0u]) of type
const(AsciiChar) to AsciiChar
std/encoding.d:374: Error: cannot implicitly convert expression (s[0u]) of type
const(AsciiChar) to AsciiChar
std/encoding.d:380: Error: cannot implicitly convert expression (s[__dollar -
1u]) of type const(AsciiChar) to AsciiChar
std/encoding.d:381: Error: cannot implicitly convert expression (s[__dollar -
1u]) of type const(AsciiChar) to AsciiChar


Other than that, it is all good to go. :)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 29 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6571




It should break std.windows.registry too, that's where I found it.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 29 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6571




I don't have windows so I can't test that. ;)

Everything is fine on the *nix side of things. For std.encoding, just replace
the three 'typedef ubyte' with 'alias ubyte xxx'

Regards

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 31 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6571





 I don't have windows so I can't test that. ;)
 
Since phobos and druntime don't use typedef any more, there should be no reliance on this bug any more. Would you like to make a pull request?
 Everything is fine on the *nix side of things. For std.encoding, just replace
 the three 'typedef ubyte' with 'alias ubyte xxx'
This didn't work for me for some reason, I think the module relies on them being distinct types. Using enums instead solved the problem. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 31 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6571


Trass3r <mrmocool gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mrmocool gmx.de



A related issue is if const is part of the typedef.

typedef const(void*) type;
void bar(void* a) {}
void main()
{
    type a;
    bar(&a);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 30 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6571


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com
            Version|D1                          |D2



23:38:39 PST ---
First off, this is a D2, not a D1 issue. D

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 20 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6571


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WONTFIX



23:39:39 PST ---
... continued

D1 does not have shared/const, etc.

Secondly, typedefs are deprecated in D2. So this is "wontfix".

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