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++/71826] New: ICE on invalid C++ code with ambiguous member lookup: tree check: expected baselink, have error_mark in tsubst_baselink, at cp/pt.c:13737


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71826

            Bug ID: 71826
           Summary: ICE on invalid C++ code with ambiguous member lookup:
                    tree check: expected baselink, have error_mark in
                    tsubst_baselink, at cp/pt.c:13737
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: su at cs dot ucdavis.edu
  Target Milestone: ---

The following C++ code causes an ICE when compiled with the current GCC trunk
on x86_64-linux-gnu in both 32-bit and 64-bit modes.  

It is a regression from 6.1.x. 

The code seems to be (mistakenly?) accepted by both Clang and ICC. 


$ g++-trunk -v
Using built-in specs.
COLLECT_GCC=g++-trunk
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/7.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-source-trunk/configure --enable-languages=c,c++,lto
--prefix=/usr/local/gcc-trunk --disable-bootstrap
Thread model: posix
gcc version 7.0.0 20160709 (experimental) [trunk revision 238191] (GCC)
$
$ clang++-3.8 -c small.cpp
$
$ g++-6.1 -c small.cpp
small.cpp: In instantiation of ‘void C<T>::f() [with T = int]’:
small.cpp:13:7:   required from here
small.cpp:7:16: error: request for member ‘i’ is ambiguous
   void f () {  i ();  }
                ^
small.cpp:3:18: note: candidates are: void B::i()
 struct B {  void i () {}  };
                  ^
small.cpp:1:36: note:                 int A<int>::i
 template < class > struct A {  int i;  };
                                    ^
$
$ g++-trunk -c small.cpp
small.cpp: In instantiation of ‘void C<T>::f() [with T = int]’:
small.cpp:13:7:   required from here
small.cpp:7:18: error: request for member ‘i’ is ambiguous
   void f () {  i ();  }
                ~~^~
small.cpp:3:18: note: candidates are: void B::i()
 struct B {  void i () {}  };
                  ^
small.cpp:1:36: note:                 int A<int>::i
 template < class > struct A {  int i;  };
                                    ^
small.cpp:7:18: internal compiler error: tree check: expected baselink, have
error_mark in tsubst_baselink, at cp/pt.c:13737
   void f () {  i ();  }
                ~~^~
0x105f7ec tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ../../gcc-source-trunk/gcc/tree.c:9751
0x6fcbf7 tree_check
        ../../gcc-source-trunk/gcc/tree.h:3030
0x6fcbf7 tsubst_baselink
        ../../gcc-source-trunk/gcc/cp/pt.c:13737
0x6e52b0 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../gcc-source-trunk/gcc/cp/pt.c:16865
0x6e48aa tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../gcc-source-trunk/gcc/cp/pt.c:16536
0x6d6cbf tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc-source-trunk/gcc/cp/pt.c:15868
0x6d735a tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc-source-trunk/gcc/cp/pt.c:15180
0x6d81f0 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc-source-trunk/gcc/cp/pt.c:15351
0x6d4bf5 instantiate_decl(tree_node*, int, bool)
        ../../gcc-source-trunk/gcc/cp/pt.c:22095
0x7218d2 instantiate_pending_templates(int)
        ../../gcc-source-trunk/gcc/cp/pt.c:22214
0x764a05 c_parse_final_cleanups()
        ../../gcc-source-trunk/gcc/cp/decl2.c:4600
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
$


----------------------------------------------


template < class > struct A {  int i;  };

struct B {  void i () {}  };

template < class T > struct C : A < T >, B
{ 
  void f () {  i ();  }
};

int main ()
{ 
  C < int > c;
  c.f();
  return 0;
}

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