[Issue 35] New: Potentially wrong code with template alias parameters and nested functions

gdc-bugzilla at gdcproject.org gdc-bugzilla at gdcproject.org
Sat Jan 12 10:17:10 PST 2013


http://gdcproject.org/bugzilla/show_bug.cgi?id=35

             Bug #: 35
           Summary: Potentially wrong code with template alias parameters
                    and nested functions
    Classification: Unclassified
           Product: GDC
           Version: development
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: Normal
         Component: gdc
        AssignedTo: ibuclaw at gdcproject.org
        ReportedBy: johannespfau at gmail.com


Created attachment 24
  --> http://gdcproject.org/bugzilla/attachment.cgi?id=24
test case 1

Test case 1 and 2 basically show the same problem: If we have a template with
access to an alias parameter, that alias parameter can be a nested function. So
the template and therefore all functions in it have access to the nested
function which essentially means those functions have to be treated as if they
were nested as well. We currently mark those functions as TREE_PUBLIC which
fails a verify check in gcc-4.7 when compiled with --enable-checking.

Basic example: (Pseudo-Code)
-------
void a()()
{
    int var;
    void b()
    {
        var = 0;
    }

    Test!b();
}

struct Test(alias t)
{
    void abc() //Marked as public, although calls nested function b
    {
        t();
    }
}
-------

Test case 2 shows that we also have to check recursively for parent templates.
I'm not sure if this could also somehow affect templates instantiated with
nested classes?

It seems the frontends hasNestedArgs and isnested members in
TemplateDeclaration could be used to check for this. Those frontend functions
don't correctly detect the second test case though:
http://d.puremagic.com/issues/show_bug.cgi?id=9292

Patch 1 shows how the frontend checking code could be used.

-- 
Configure issuemail: http://gdcproject.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all issue changes.


More information about the D.gnu mailing list