This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/17011] [3.4/3.5 regression] invalid default parameter diagnosed too late


------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]