Thread overview
[Issue 5461] New: Invalid declaration for auto functions in .di files generated by DMD -H
Jan 19, 2011
Nicolas Sicard
Jan 20, 2011
Nicolas Sicard
Apr 22, 2012
SomeDude
May 09, 2012
Trass3r
May 09, 2012
LightBender
May 09, 2012
LightBender
Jan 16, 2013
Walter Bright
January 19, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5461

           Summary: Invalid declaration for auto functions in .di files
                    generated by DMD -H
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: dransic@free.fr


--- Comment #0 from Nicolas Sicard <dransic@free.fr> 2011-01-19 12:00:51 PST ---
When compiling "complex" non-templated auto functions, e.g.:

auto foo() {
    struct Bar {
        int a;
    }
    auto bar = Bar(42);
    return bar;
}

with -H option, the generated .di file contains:

auto foo();

which is a (rightly) invalid declaration statement. I think that either foo's body should be included in the .di file or that a warning/error should be thrown on compilation of such a function with the -H switch.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 20, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5461



--- Comment #1 from Nicolas Sicard <dransic@free.fr> 2011-01-20 08:25:32 PST ---
Created an attachment (id=872)
patch of func.c in DMD 2.051

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 22, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5461


SomeDude <lovelydear@mailmetrash.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lovelydear@mailmetrash.com


--- Comment #2 from SomeDude <lovelydear@mailmetrash.com> 2012-04-22 15:17:53 PDT ---
With 2.059

dmd -H now produces:

// D import file generated from 'bug.d'
import std.stdio;
struct Foo
{
    int x;
}
void main();

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 09, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5461


Trass3r <mrmocool@gmx.de> changed:

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


--- Comment #3 from Trass3r <mrmocool@gmx.de> 2012-05-09 18:33:11 CEST ---
?
git dmd still produces 'auto foo();' for me.

I think the patch could be more complex though.
If it's a Voldemort type the whole body needs to be included.
But what if it's a "simple" type? Then you could just print out the inferred
type.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 09, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5461


LightBender <adamw@prospectivesoftware.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |adamw@prospectivesoftware.c
                   |                            |om


--- Comment #4 from LightBender <adamw@prospectivesoftware.com> 2012-05-09 09:57:54 PDT ---
(In reply to comment #3)
> ?
> git dmd still produces 'auto foo();' for me.
> 
> I think the patch could be more complex though.
> If it's a Voldemort type the whole body needs to be included.
> But what if it's a "simple" type? Then you could just print out the inferred
> type.

This pull fixes this problem and a bunch of others: https://github.com/D-Programming-Language/dmd/pull/928. However, it currently fails to build on Linux and fails the unittests on Windows thanks to a problem with the dur template function in std.datetime. The solution used by this pull is to include the function body of the auto-function as that was needed to allow Phobos to build correctly using the DRT DI files.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 09, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5461



--- Comment #5 from LightBender <adamw@prospectivesoftware.com> 2012-05-09 10:04:56 PDT ---
(In reply to comment #4)
> (In reply to comment #3)
> > ?
> > git dmd still produces 'auto foo();' for me.
> > 
> > I think the patch could be more complex though.
> > If it's a Voldemort type the whole body needs to be included.
> > But what if it's a "simple" type? Then you could just print out the inferred
> > type.
> 
> This pull fixes this problem and a bunch of others: https://github.com/D-Programming-Language/dmd/pull/928. However, it currently fails to build on Linux and fails the unittests on Windows thanks to a problem with the dur template function in std.datetime. The solution used by this pull is to include the function body of the auto-function as that was needed to allow Phobos to build correctly using the DRT DI files.

I forgot to mention that DMD does not know the type of an auto-function when DI files are generated. No semantic analysis has been performed and since semantic analysis could change the layout of a module you wouldn't want it to be performed.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 16, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=5461


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
           Platform|Other                       |All
         Resolution|                            |FIXED


--- Comment #6 from Walter Bright <bugzilla@digitalmars.com> 2013-01-16 14:59:22 PST ---
https://github.com/D-Programming-Language/dmd/pull/1487

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