D.gnu - [Issue 35] New: Potentially wrong code with template alias
- gdc-bugzilla gdcproject.org (55/55) Jan 12 2013 http://gdcproject.org/bugzilla/show_bug.cgi?id=35
http://gdcproject.org/bugzilla/show_bug.cgi?id=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 gdcproject.org
ReportedBy: johannespfau 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.
Jan 12 2013








gdc-bugzilla gdcproject.org