www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4602] New: Header generation turns 'typeof(x)(...)' into C-style cast

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

           Summary: Header generation turns 'typeof(x)(...)' into C-style
                    cast
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bugzilla kyllingen.net



03:48:33 PDT ---
When typeof(x)(...) is used as a struct literal, the compiler adds parentheses
around typeof(x) in the generated .di file.  When the .di file is later used,
the compiler interprets (typeof(x)) as a C-style cast.

I tend to use

   return typeof(return)(...);

a lot in generic code, and this issue makes header files completely unusable to
me.


Test case:

$ cat test.d
struct S { int i; }
S foo() { return typeof(return)(123); }

$ dmd -c -o- -H test.d

$ cat test.di
// D import file generated from 'test.d'
struct S
{
    int i;
}
S foo()
{
return (typeof(return))(123);
}

$ dmd -c -o- test.di
test.di(8): C style cast illegal, use cast(typeof(return))123

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


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
                 CC|                            |clugdbug yahoo.com.au
           Severity|normal                      |critical


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


Don <clugdbug yahoo.com.au> changed:

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



Fixed http://www.dsource.org/projects/dmd/changeset/629
as part of bug 4713.

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