This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/21903] Default argument of template function causes a compile-time error
- From: "nathan at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 6 Jun 2005 09:34:59 -0000
- Subject: [Bug c++/21903] Default argument of template function causes a compile-time error
- References: <20050603201311.21903.SSacek@appsecinc.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From nathan at gcc dot gnu dot org 2005-06-06 09:34 -------
ug. This looks like a defect in the std. As has been pointed out, we cannot
parse the default argument until the outer class is complete -- because the
default argument of the nested class can legitimately call or access a static
member of the outer class that happens to be declared after the nested class.
However after the definition of the nested class, that template is complete
according to the language, and should therefore be instantiable. When
instantiating it, we have to instantiate the declarations of all its member
functions [14.7.1]. Aha! 'but not ... the default arguments'. Default arguments
are implicitly instantiated 'when the function is called in a context that
requires the value of that default argument'.
So, we need to remember we're instantiating a function declaration containing an
unparsed default arg -- and then DTRT when the arg gets parsed.
This isn't a regression (is it?), so won't be fixed until 4.1 is released.
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |nathan at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
Last reconfirmed|2005-06-04 10:46:16 |2005-06-06 09:34:54
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21903