This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/17011] [3.4/3.5 regression] invalid default parameter diagnosed too late
- From: "bangerth at dealii dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 Aug 2004 23:59:48 -0000
- Subject: [Bug c++/17011] [3.4/3.5 regression] invalid default parameter diagnosed too late
- References: <20040812193920.17011.reichelt@gcc.gnu.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From bangerth at dealii dot org 2004-08-12 23:59 -------
No, the type of &a is of course the same as the type of &this->a, i.e.
a pointer to an object, not a pointer-to-member. For that you would
have to use &B<T>::a. The invalid part in the code Volker showed is
the implicit reference to this->, which is explicitly not allowed
by the standard.
One of the reasons why you may not want to parse default arguments
at template definition time is that you cannot know whether this code,
for example, is going to be valid or not:
------------------
template <typename T> struct X {
int g (int = T(1));
};
------------------
(Think a template type T for which there is no constructor that takes
an integer.) Now, you will say that here we have a dependent call, whereas
in the original case we do not, but that may actually be hard to
figure out in some cases. I guess that it's cases like these that led
the committee to suggest that default arguments are only evaluated at the
time of use.
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17011