User account creation filtered due to spam.

Bug 10147 - [3.3/3.4 regression] Confusing error message for invalid template function argument
Summary: [3.3/3.4 regression] Confusing error message for invalid template function ar...
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.2.2
: P3 normal
Target Milestone: 3.3.2
Assignee: Not yet assigned to anyone
Keywords: diagnostic
Depends on:
Reported: 2003-03-19 09:36 UTC by lalle
Modified: 2004-01-17 04:22 UTC (History)
1 user (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed: 2003-08-05 04:19:07


Note You need to log in before you can comment on or make changes to this bug.
Description lalle 2003-03-19 09:36:00 UTC
snaga:tmp> cat bug.ii 
namespace N1

typedef long A;

struct B
  virtual A a() const;

struct D : public B
  A a() const;


N1::D d();

namespace N2

struct A {};

template < class T > T tf(const T &)
  return T();

void f(const N1::B & b)
 tf< A >(b.a());


void f2()

snaga:tmp> /opt/gcc-3.2.2/bin/g++ -c bug.ii 
bug.ii: In function `void N2::f(const N1::B&)':
bug.ii:32: could not convert `(**(+b)->N1::B::_vptr.B)((+b))' to `const N2::A&'
bug.ii:26: in passing argument 1 of `T N2::tf(const T&) [with T = N2::A]'

snaga:tmp> /opt/gcc-3.2.2/bin/g++ -v 
Reading specs from /opt/gcc-3.2.2/lib/gcc-lib/i686-pc-linux-gnu/3.2.2/specs
Configured with: /tmp/post_install/gcc-3.2.2/configure --enable-languages=c,c++ --prefix=/opt/gcc-3.2.2
Thread model: posix
gcc version 3.2.2


snaga:tmp> uname -a
Linux 2.4.19 #7 Fri Nov 29 15:22:22 CET 2002 i686 i686 i386 GNU/Linux

snaga:tmp> cat /etc/redhat-release 
Red Hat Linux release 8.0 (Psyche)
Comment 1 Wolfgang Bangerth 2003-03-20 02:09:19 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed. I think this is a regression: 2.95 said on
    this code In function `void N2::f(const N1::B &)': conversion from `A' to non-scalar type `N2::A' requested in passing argument 1 of `N2::tf<N2::A>(const N2::A &)'
    This is not entirely accurate, since A is actually N1::A,
    but the message was much clearer than what we get presently
    (in 3.2, 3.3 and mainline).
Comment 2 Mark Mitchell 2003-07-11 22:16:49 UTC
Postponed until GCC 3.3.2.
Comment 3 CVS Commits 2003-10-07 07:07:14 UTC
Subject: Bug 10147

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	2003-10-07 07:07:08

Modified files:
	gcc/cp         : ChangeLog call.c cxx-pretty-print.c 
	                 cxx-pretty-print.h decl.c init.c 
	gcc/testsuite  : ChangeLog 
	gcc/testsuite/g++.dg/other: error4.C 
	gcc/testsuite/g++.dg/template: ptrmem4.C 
Added files:
	gcc/testsuite/g++.dg/ext: attrib8.C 
	gcc/testsuite/g++.dg/init: new9.C 

Log message:
	PR c++/10147
	* call.c (initialize_reference): Tweak error message.
	PR c++/12337
	* init.c (build_new_1): Make sure that the expression returned is
	not an lvalue.
	PR c++/12344, c++/12236, c++/8656
	* decl.c (start_function): Do not ignore attributes embedded in a
	function declarator.
	PR c++/12337
	* g++.dg/init/new9.C: New test.
	PR c++/12334, c++/12236, c++/8656
	* g++.dg/ext/attrib8.C: New test.


Comment 4 Mark Mitchell 2003-10-07 07:08:02 UTC
Fixed in GCC 3.4.  In GCC 3.3.2, the GCC 2.95 error message was restored, which
is good enough.
Comment 5 CVS Commits 2003-10-08 06:34:08 UTC
Subject: Bug 10147

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	2003-10-08 06:34:05

Modified files:
	gcc/testsuite/g++.dg/template: ptrmem4.C 

Log message:
	* g++.dg/template/ptrmem4.C: Revise in view of fixes for PR