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

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