public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/35008]  New: Bug in processing nested typedef in nested template class in method definition
@ 2008-01-29  4:13 wirawan0 at gmail dot com
  2008-01-29 13:34 ` [Bug c++/35008] " rguenth at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: wirawan0 at gmail dot com @ 2008-01-29  4:13 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2393 bytes --]

The following testcase fails to compile: 

template <typename data1> struct outer1
{
    typedef int my_value_type;  // define a nested datatype

    template <typename servert> struct inner1
    {
        typedef outer1<data1> myboss;
// borrow the boss's datatype << -- don't reduce or change this one:
        typedef typename myboss::my_value_type my_value_type;
        my_value_type return_x();
    };

};

// g++ 4 choked on this one:
template <typename data1>
template <typename servert>
typename outer1<data1>::template inner1<servert>::my_value_type
outer1<data1>::inner1<servert>::return_x()
{
    return 4;
}

void testme()
{
    outer1<float>::inner1<int> Inner1;
    int rslt = Inner1.return_x(); // to instantiate and cause error
}


It is basically like this:
* outer1 class template has a nested datatype called "my_value_type"
* inner1 borrows the "my_value_type" from outer1 (its parent)

Then when we want to instantiate return_x() above, g++ gives the following
error:

template-typename4.cpp:19: error: prototype for ‘typename
outer1<data1>::inner1<servert>::my_value_type
outer1<data1>::inner1<servert>::return_x()’ does not match any in class
‘outer1<data1>::inner1<servert>’
template-typename4.cpp:10: error: candidate is: typename
outer1<data1>::my_value_type outer1<data1>::inner1<servert>::return_x()
template-typename4.cpp:19: error: template definition of non-template ‘typename
outer1<data1>::inner1<servert>::my_value_type
outer1<data1>::inner1<servert>::return_x()’

I can work around this by changing line 18 above:

  typename outer1<data1>::template inner1<servert>::my_value_type

to

  typename outer1<data1>::my_value_type

then it would compile. But I think this is a bug. It used to compile with g++
3. Other compilers such as Intel C++ (version 9.1), PGI C++ 7 all accept this
language construct.


-- 
           Summary: Bug in processing nested typedef in nested template
                    class in method definition
           Product: gcc
           Version: 4.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: wirawan0 at gmail dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35008


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-03-31 15:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-29  4:13 [Bug c++/35008] New: Bug in processing nested typedef in nested template class in method definition wirawan0 at gmail dot com
2008-01-29 13:34 ` [Bug c++/35008] " rguenth at gcc dot gnu dot org
2008-01-29 15:17 ` wirawan0 at gmail dot com
2008-01-29 15:23 ` wirawan0 at gmail dot com
2008-01-29 15:35 ` rguenth at gcc dot gnu dot org
2008-01-29 15:37 ` rguenth at gcc dot gnu dot org
2008-12-29 14:35 ` [Bug c++/35008] [4.2 Regression] " pinskia at gcc dot gnu dot org
2009-03-31 15:05 ` jsm28 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).