Bug 18436 - [3.4/4.0 Regression] ICE in perform_or_defer_access_check (binfo is NULL)
Summary: [3.4/4.0 Regression] ICE in perform_or_defer_access_check (binfo is NULL)
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.3
: P2 critical
Target Milestone: 3.4.4
Assignee: Mark Mitchell
URL:
Keywords: ice-on-valid-code, monitored
Depends on:
Blocks:
 
Reported: 2004-11-12 00:10 UTC by Sylvain Pion
Modified: 2004-11-12 21:58 UTC (History)
6 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2004-11-12 11:58:49


Attachments
preprocessed source code (185.33 KB, application/octet-stream)
2004-11-12 00:12 UTC, Sylvain Pion
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sylvain Pion 2004-11-12 00:10:15 UTC
I get an ICE with the attached pre-processed code.
I get it with g++ 3.4.3, as well as 4.0.0-20041111.
With no particular command line option (-O2 or nothing produces it).
Comment 1 Sylvain Pion 2004-11-12 00:12:33 UTC
Created attachment 7523 [details]
preprocessed source code
Comment 2 Andrew Pinski 2004-11-12 00:18:52 UTC
Hmm, this looks related to PR 17829 (but that was fixed and this is still broken).
Comment 3 Volker Reichelt 2004-11-12 10:22:45 UTC
Reduced testcase:

=====================================
struct A
{
    static void foo(A);
};

struct B
{
    friend void foo(B);
};

template<typename T> struct C : T
{
    C() { foo(T()); }
};

C<A> c;
=====================================
Comment 4 Jakub Jelinek 2004-11-12 10:35:26 UTC
I see segfault in perform_or_defer_access_check too, on:
template <class T1, class T2>
struct P
{
  T1 t1;
  T2 t2;
  P () : t1(), t2() { }
  template <class U1, class U2>
  P (const P<U1, U2> &x) : t1(x.t1), t2(x.t2) { }
};

template <typename T>
inline void
f (T &x, T &y)
{
  const T t = x; x = y; y = t;
}

template <class T>
struct A
{
  static void f (T &x, T &y) { T t = x; x = y; y = t; }
};

template <class T>
struct B : public A<T>
{
  static void g (T *x, T *y) { f (*y, *x); }
};

int
foo ()
{
  P<long, long> *a, *b;
  B<P<long, long> >::g (a, b);
}

Works with GCC 3.3, segfaults with 3.4.3 and 4.0 current.
Comment 5 Volker Reichelt 2004-11-12 11:58:45 UTC
The examples from comment #3 and comment #4 can both be reduced to

=====================================
void foo(int);

struct A
{
    static void foo(A);
};

template<typename T> struct B : T
{
    B() { foo(T()); }
};

B<A> b;
=====================================

I'm not sure whether this is valid or not - icc for example rejects the
code in strict mode.
Comment 6 Volker Reichelt 2004-11-12 12:26:55 UTC
Mark, the ICE on mainline appears with your patch
http://gcc.gnu.org/ml/gcc-cvs/2004-09/msg01274.html
Comment 7 Andrew Pinski 2004-11-12 12:42:13 UTC
: Search converges between 2004-09-27-014001-trunk (#563) and 2004-09-27-161002-trunk 
(#564).
: Search converges between 2004-09-27-004002-3.4 (#82) and 2004-09-28-004001-3.4 (#83).
Comment 8 GCC Commits 2004-11-12 21:47:28 UTC
Subject: Bug 18436

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2004-11-12 21:47:13

Modified files:
	gcc/cp         : ChangeLog decl.c decl2.c parser.c pt.c tree.c 
	gcc/testsuite  : ChangeLog 
	gcc/testsuite/g++.dg/ext: vla1.C vlm1.C 
	gcc/testsuite/g++.dg/template: crash2.C 
Added files:
	gcc/testsuite/g++.dg/parse: cond1.C 
	gcc/testsuite/g++.dg/template: array9.C call3.C ptrmem11.C 

Log message:
	PR c++/18389
	* decl.c (start_decl): Make sure to set *pop_scope_p.  Return
	error_mark_node to indicate errors.
	
	PR c++/18429
	* parser.c (cp_parser_direct_declarator): Disallow non-constant
	array bounds when not inside a function.
	
	PR c++/18436
	* pt.c (tsubst_copy_and_build): Do not do Koenig lookup when an
	unqualified name resolves to a member function.
	
	PR c++/18407
	* pt.c (tsubst_copy_and_build): Handle qualified names used from a
	derived class correctly.
	
	* decl2.c (import_export_decl): Fix typo in comment.
	* tree.c (pod_type_p): Likewise.
	
	PR c++/18389
	* g++.dg/parse/cond1.C: New test.
	
	PR c++/18429
	* g++.dg/template/array9.C: New test.
	* g++.dg/ext/vla1.C: Adjust error messages.
	* g++.dg/ext/vlm1.C: Likewise.
	* g++.dg/template/crash2.C: Likewise.
	
	PR c++/18436
	* g++.dg/template/call3.C: New test.
	
	PR c++/18407
	* g++.dg/template/ptrmem11.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4480&r2=1.4481
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1326&r2=1.1327
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl2.c.diff?cvsroot=gcc&r1=1.756&r2=1.757
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.278&r2=1.279
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.944&r2=1.945
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/tree.c.diff?cvsroot=gcc&r1=1.418&r2=1.419
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4588&r2=1.4589
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/ext/vla1.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/ext/vlm1.C.diff?cvsroot=gcc&r1=1.2&r2=1.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/cond1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/array9.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/call3.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/ptrmem11.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/crash2.C.diff?cvsroot=gcc&r1=1.2&r2=1.3

Comment 9 GCC Commits 2004-11-12 21:57:43 UTC
Subject: Bug 18436

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	mmitchel@gcc.gnu.org	2004-11-12 21:57:31

Modified files:
	gcc/cp         : decl.c pt.c ChangeLog 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/parse: cond1.C 
	gcc/testsuite/g++.dg/template: call3.C ptrmem11.C 

Log message:
	PR c++/18389
	* decl.c (start_decl): Make sure to set *pop_scope_p.  Return
	error_mark_node to indicate errors.
	
	PR c++/18436
	* pt.c (tsubst_copy_and_build): Do not do Koenig lookup when an
	unqualified name resolves to a member function.
	
	PR c++/18407
	* pt.c (tsubst_copy_and_build): Handle qualified names used from a
	derived class correctly.
	
	* decl2.c (import_export_decl): Fix typo in comment.
	* tree.c (pod_type_p): Likewise.
	
	PR c++/18389
	* g++.dg/parse/cond1.C: New test.
	
	PR c++/18436
	* g++.dg/template/call3.C: New test.
	
	PR c++/18407
	* g++.dg/template/ptrmem11.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.1174.2.27&r2=1.1174.2.28
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.816.2.45&r2=1.816.2.46
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.178&r2=1.3892.2.179
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.308&r2=1.3389.2.309
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/cond1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/call3.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/ptrmem11.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1

Comment 10 Mark Mitchell 2004-11-12 21:58:51 UTC
Fixed in GCC 3.4.4.