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...
Status: RESOLVED FIXED
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
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2003-03-19 09:36 UTC by lalle
Modified: 2004-01-17 04:22 UTC (History)
1 user (show)

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


Attachments

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()
{
  N2::f(d());
}

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

Release:
3.2.2

Environment:
snaga:tmp> uname -a
Linux snaga.sics.se 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
    
    x.cc: In function `void N2::f(const N1::B &)':
    x.cc:32: conversion from `A' to non-scalar type `N2::A' requested
    x.cc:26: 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).
    
    W.
Comment 2 Mark Mitchell 2003-07-11 22:16:49 UTC
Postponed until GCC 3.3.2.
Comment 3 GCC Commits 2003-10-07 07:07:14 UTC
Subject: Bug 10147

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	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.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3717&r2=1.3718
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&r1=1.437&r2=1.438
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cxx-pretty-print.c.diff?cvsroot=gcc&r1=1.7&r2=1.8
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cxx-pretty-print.h.diff?cvsroot=gcc&r1=1.4&r2=1.5
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1139&r2=1.1140
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/init.c.diff?cvsroot=gcc&r1=1.344&r2=1.345
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3099&r2=1.3100
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/ext/attrib8.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/new9.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/other/error4.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/ptrmem4.C.diff?cvsroot=gcc&r1=1.1&r2=1.2

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 GCC Commits 2003-10-08 06:34:08 UTC
Subject: Bug 10147

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	mmitchel@gcc.gnu.org	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
	c++/10147.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/ptrmem4.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.1.2.1&r2=1.1.2.2