Test file is only 30 lines (t5.cxx, the t5.ii is indentical and is included at
the end. Comments explain the bug:


template<int W>
class mc_foo {
  int _d;
public:
  mc_foo() {}
  mc_foo(int x) { _d = x; }
  mc_foo(const mc_foo &x) { _d = x._d; }
                                                                               
                                                                                
    
  template<int W2>
  void f(int i) {}
};
                                                                               
                                                                                
    
template <int W3>
void g( mc_foo<W3> val) {
                                                                               
                                                                                
    
  mc_foo<16> val2 = val;
  mc_foo<W3> val3 = val;    // W3 == 16 in this example
                                                                               
                                                                                
    
  // the two following lines should be equivalent, but gcc3.4.3 is generating 
error
  // on val3.f<16>(0). It seems like val3 is not fully resolved and gcc then 
thinks
  // "<" is "less than" rather than the syntax for template
                                                                               
                                                                                
    
  val2.f<16>(0);  // this works fine
  val3.f<16>(0);  // this produces error "invalid use of member (did you forget
the `&' ?)"
}
                                                                               
                                                                                
    
int main() {
  mc_foo<16> y(1);
  g(y);
}




 ~/local/bin/c++ -v -save-temps t5.cxx
Reading specs from
/.automount/streak/root/scratch1/takach/bin/../lib/gcc/i686-pc-linux-gnu/3.4.3/specs
Configured with: ./configure
Thread model: posix
gcc version 3.4.3
 
/.automount/streak/root/scratch1/takach/bin/../libexec/gcc/i686-pc-linux-gnu/3.4.3/cc1plus
-E -quiet -v -iprefix
/.automount/streak/root/scratch1/takach/bin/../lib/gcc/i686-pc-linux-gnu/3.4.3/
-D_GNU_SOURCE t5.cxx -mtune=pentiumpro -o t5.ii
ignoring nonexistent directory
"/.automount/streak/root/scratch1/takach/bin/../lib/gcc/i686-pc-linux-gnu/3.4.3/../../../../i686-pc-linux-gnu/include"
ignoring duplicate directory
"/user/takach/local/lib/gcc/i686-pc-linux-gnu/3.4.3/../../../../include/c++/3.4.3"
ignoring duplicate directory
"/user/takach/local/lib/gcc/i686-pc-linux-gnu/3.4.3/../../../../include/c++/3.4.3/i686-pc-linux-gnu"
ignoring duplicate directory
"/user/takach/local/lib/gcc/i686-pc-linux-gnu/3.4.3/../../../../include/c++/3.4.3/backward"
ignoring nonexistent directory "NONE/include"
ignoring duplicate directory
"/user/takach/local/lib/gcc/i686-pc-linux-gnu/3.4.3/include"
ignoring nonexistent directory
"/user/takach/local/lib/gcc/i686-pc-linux-gnu/3.4.3/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 
/.automount/streak/root/scratch1/takach/bin/../lib/gcc/i686-pc-linux-gnu/3.4.3/../../../../include/c++/3.4.3
 
/.automount/streak/root/scratch1/takach/bin/../lib/gcc/i686-pc-linux-gnu/3.4.3/../../../../include/c++/3.4.3/i686-pc-linux-gnu
 
/.automount/streak/root/scratch1/takach/bin/../lib/gcc/i686-pc-linux-gnu/3.4.3/../../../../include/c++/3.4.3/backward
 
/.automount/streak/root/scratch1/takach/bin/../lib/gcc/i686-pc-linux-gnu/3.4.3/include
 /usr/local/include
 /usr/include
End of search list.
 
/.automount/streak/root/scratch1/takach/bin/../libexec/gcc/i686-pc-linux-gnu/3.4.3/cc1plus
-fpreprocessed t5.ii -quiet -dumpbase t5.cxx -mtune=pentiumpro -auxbase t5
-version -o t5.s
GNU C++ version 3.4.3 (i686-pc-linux-gnu)
        compiled by GNU C version 3.2.3 20030502 (Red Hat Linux 3.2.3-34).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
t5.cxx: In function `void g(mc_foo<W3>) [with int W3 = 16]':
t5.cxx:29:   instantiated from here
t5.cxx:24: error: invalid use of member (did you forget the `&' ?)


Contents of t5.ii
# 1 "t5.cxx"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "t5.cxx"
template<int W>
class mc_foo {
  int _d;
public:
  mc_foo() {}
  mc_foo(int x) { _d = x; }
  mc_foo(const mc_foo &x) { _d = x._d; }
                                                                               
                                                                                
    
  template<int W2>
  void f(int i) {}
};
                                                                               
                                                                                
    
template <int W3>
void g( mc_foo<W3> val) {
                                                                               
                                                                                
    
  mc_foo<16> val2 = val;
  mc_foo<W3> val3 = val;
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                    
  val2.f<16>(0);
  val3.f<16>(0);
}
                                                                               
                                                                                
    
int main() {
  mc_foo<16> y(1);
  g(y);
}

-- 
           Summary: Compile error on template member function called from
                    template function
           Product: gcc
           Version: 3.4.3
            Status: UNCONFIRMED
          Severity: critical
          Priority: P1
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: andres_takach at mentor dot com
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: 2.4.21-15.ELsmp  #1 i686 i686 i386


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

Reply via email to