public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/20172] New: member function template declaration not instantiated during the instantiation of the enclosing class template @ 2005-02-23 20:24 SWElef at post dot sk 2005-02-23 20:26 ` [Bug c++/20172] " SWElef at post dot sk ` (4 more replies) 0 siblings, 5 replies; 6+ messages in thread From: SWElef at post dot sk @ 2005-02-23 20:24 UTC (permalink / raw) To: gcc-bugs gcc accepts the following ill-formed code (tested with gcc3.4.2 (mingw) and various cygwin versions (from 3.3.1 to 3.4.3 and an experimental snapshot 4.0.0-20050130) ): template <typename T> struct foo{ template <T t> static void bar() { } }; template <typename T> foo<T> tester(T) { return foo<T>(); } int main(){ tester(1.2); return 0; } std:14.7.1/1 says ... The implicit instantiation of a class template specialization causes the implicit instantiation of the declarations, but not of the definitions or default arguments, of the class member functions, member classes, static data members and _member_templates_; ... Thus, the implicit instantiation of struct foo<double> causes the instantiation of declaration template <double t> void foo<double>::bar(); which is ill-formed and should be diagnosed. Remark 1: The signature of bar is unimportant, it just has to be a function. If one declares a nested "template <T t> struct S;" gcc correctly complains when instantiating foo<double>. Remark 2: Shorter testcase consists of a declaration of the template foo and an explicit instantiation of foo<double>, but the wording for implicit instantiation is much cleaner in this case so I decided to use it. Regards, Vladimir Marko -- Summary: member function template declaration not instantiated during the instantiation of the enclosing class template Product: gcc Version: 3.4.3 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: SWElef at post dot sk CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20172 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/20172] member function template declaration not instantiated during the instantiation of the enclosing class template 2005-02-23 20:24 [Bug c++/20172] New: member function template declaration not instantiated during the instantiation of the enclosing class template SWElef at post dot sk @ 2005-02-23 20:26 ` SWElef at post dot sk 2005-02-25 16:30 ` reichelt at gcc dot gnu dot org ` (3 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: SWElef at post dot sk @ 2005-02-23 20:26 UTC (permalink / raw) To: gcc-bugs -- What |Removed |Added ---------------------------------------------------------------------------- Keywords| |accepts-invalid http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20172 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/20172] member function template declaration not instantiated during the instantiation of the enclosing class template 2005-02-23 20:24 [Bug c++/20172] New: member function template declaration not instantiated during the instantiation of the enclosing class template SWElef at post dot sk 2005-02-23 20:26 ` [Bug c++/20172] " SWElef at post dot sk @ 2005-02-25 16:30 ` reichelt at gcc dot gnu dot org 2005-06-10 9:58 ` [Bug c++/20172] Invalid non-type template parameters not diagnosed reichelt at gcc dot gnu dot org ` (2 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: reichelt at gcc dot gnu dot org @ 2005-02-25 16:30 UTC (permalink / raw) To: gcc-bugs ------- Additional Comments From reichelt at gcc dot gnu dot org 2005-02-25 09:13 ------- Confirmed. Accepted since at least gcc 2.95.3. Reduced testcase: ================================ template<typename T> struct A { template<T> void foo(); }; A<double> a; ================================ Even A<void> is accepted. -- What |Removed |Added ---------------------------------------------------------------------------- CC| |reichelt at gcc dot gnu dot | |org Status|UNCONFIRMED |NEW Ever Confirmed| |1 Keywords| |monitored Last reconfirmed|0000-00-00 00:00:00 |2005-02-25 09:13:12 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20172 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/20172] Invalid non-type template parameters not diagnosed 2005-02-23 20:24 [Bug c++/20172] New: member function template declaration not instantiated during the instantiation of the enclosing class template SWElef at post dot sk 2005-02-23 20:26 ` [Bug c++/20172] " SWElef at post dot sk 2005-02-25 16:30 ` reichelt at gcc dot gnu dot org @ 2005-06-10 9:58 ` reichelt at gcc dot gnu dot org 2005-07-12 16:08 ` cvs-commit at gcc dot gnu dot org 2005-07-13 10:07 ` reichelt at gcc dot gnu dot org 4 siblings, 0 replies; 6+ messages in thread From: reichelt at gcc dot gnu dot org @ 2005-06-10 9:58 UTC (permalink / raw) To: gcc-bugs ------- Additional Comments From reichelt at gcc dot gnu dot org 2005-06-10 09:58 ------- Actually gcc does instantiate the declarations. It just doesn't check whether the non-type template arguments are valid in this situation. Adjusting the summary accordingly. Patch posted. -- What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|unassigned at gcc dot gnu |reichelt at gcc dot gnu dot |dot org |org URL| |http://gcc.gnu.org/ml/gcc- | |patches/2005- | |06/msg00952.html Status|NEW |ASSIGNED Keywords| |patch Summary|member function template |Invalid non-type template |declaration not instantiated|parameters not diagnosed |during the instantiation of | |the enclosing class template| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20172 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/20172] Invalid non-type template parameters not diagnosed 2005-02-23 20:24 [Bug c++/20172] New: member function template declaration not instantiated during the instantiation of the enclosing class template SWElef at post dot sk ` (2 preceding siblings ...) 2005-06-10 9:58 ` [Bug c++/20172] Invalid non-type template parameters not diagnosed reichelt at gcc dot gnu dot org @ 2005-07-12 16:08 ` cvs-commit at gcc dot gnu dot org 2005-07-13 10:07 ` reichelt at gcc dot gnu dot org 4 siblings, 0 replies; 6+ messages in thread From: cvs-commit at gcc dot gnu dot org @ 2005-07-12 16:08 UTC (permalink / raw) To: gcc-bugs ------- Additional Comments From cvs-commit at gcc dot gnu dot org 2005-07-12 16:08 ------- Subject: Bug 20172 CVSROOT: /cvs/gcc Module name: gcc Changes by: nathan@gcc.gnu.org 2005-07-12 16:07:39 Modified files: gcc/cp : ChangeLog pt.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/template: nontype12.C Log message: cp: PR c++/20172 * pt.c (tsubst_template_parms): Check for invalid non-type parameters. testsuite: PR c++/20172 * g++.dg/template/nontype12.C : New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4817&r2=1.4818 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.1014&r2=1.1015 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5752&r2=1.5753 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/nontype12.C.diff?cvsroot=gcc&r1=NONE&r2=1.1 -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20172 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/20172] Invalid non-type template parameters not diagnosed 2005-02-23 20:24 [Bug c++/20172] New: member function template declaration not instantiated during the instantiation of the enclosing class template SWElef at post dot sk ` (3 preceding siblings ...) 2005-07-12 16:08 ` cvs-commit at gcc dot gnu dot org @ 2005-07-13 10:07 ` reichelt at gcc dot gnu dot org 4 siblings, 0 replies; 6+ messages in thread From: reichelt at gcc dot gnu dot org @ 2005-07-13 10:07 UTC (permalink / raw) To: gcc-bugs ------- Additional Comments From reichelt at gcc dot gnu dot org 2005-07-13 09:41 ------- Fixed on mainline. -- What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED Resolution| |FIXED Target Milestone|--- |4.1.0 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20172 ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2005-07-13 9:41 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2005-02-23 20:24 [Bug c++/20172] New: member function template declaration not instantiated during the instantiation of the enclosing class template SWElef at post dot sk 2005-02-23 20:26 ` [Bug c++/20172] " SWElef at post dot sk 2005-02-25 16:30 ` reichelt at gcc dot gnu dot org 2005-06-10 9:58 ` [Bug c++/20172] Invalid non-type template parameters not diagnosed reichelt at gcc dot gnu dot org 2005-07-12 16:08 ` cvs-commit at gcc dot gnu dot org 2005-07-13 10:07 ` reichelt at gcc dot gnu dot org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).