User account creation filtered due to spam.

Bug 8503 - [3.2 regression] strange behaviour of function types
Summary: [3.2 regression] strange behaviour of function types
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.2
: P3 normal
Target Milestone: ---
Assignee: Nathan Sidwell
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2002-11-08 04:46 UTC by John Maddock
Modified: 2003-07-25 17:33 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
8503.cc (269 bytes, application/octet-stream)
2003-05-21 15:16 UTC, John Maddock
Details

Note You need to log in before you can comment on or make changes to this bug.
Description John Maddock 2002-11-08 04:46:03 UTC
The example code attached behaves strangely with function types, basically template argument deduction finds cv-qualified reference or pointer to function overloads, rather than the non-cv qualified version. Since cv-qualifiers are illegal on function types this is particular annoying (in fact gcc emits a warning about this).  template partial specializations behave in the same way - and this is currently causing a problem for boost's type traits code.

Release:
gcc-3.2

Environment:
Suse Linux 7.0
Comment 1 Paolo Carlini 2002-11-08 05:07:17 UTC
Responsible-Changed-From-To: unassigned->paolo
Responsible-Changed-Why: .
Comment 2 Paolo Carlini 2002-11-08 05:07:17 UTC
State-Changed-From-To: open->feedback
State-Changed-Why: Unfortunately, the example code got lost.
    Could you possibly send it to me privately? I will complete
    the PR with it.
    Thanks, Paolo.
Comment 3 Paolo Carlini 2002-11-09 07:00:28 UTC
State-Changed-From-To: feedback->open
State-Changed-Why: Testcase received.
Comment 4 Paolo Carlini 2002-11-09 07:01:14 UTC
Responsible-Changed-From-To: paolo->unassigned
Responsible-Changed-Why: .
Comment 5 Paolo Carlini 2002-11-09 07:09:50 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Current mainline is Ok:
    paolo:~> a.out
    non-const
    non-const
    non-const
    On the other hand, 3_2-branch is affected by the bug:
    paolo:~> a.out
    const
    const
    const
    Regression from 3.0.4 -> high priority.
Comment 6 John Maddock 2002-11-09 11:20:17 UTC
From: "John Maddock" <john_maddock@compuserve.com>
To: <paolo@gcc.gnu.org>,
	<gcc-bugs@gcc.gnu.org>,
	<gcc-prs@gcc.gnu.org>,
	<john_maddock@compuserve.com>,
	<nobody@gcc.gnu.org>,
	<gcc-gnats@gcc.gnu.org>
Cc:  
Subject: Re: c++/8503: strange behaviour of function types.
Date: Sat, 9 Nov 2002 11:20:17 -0000

 This is a multi-part message in MIME format.
 
 ------=_NextPart_000_0026_01C287E1.FB7F23C0
 Content-Type: text/plain;
 	charset="iso-8859-1"
 Content-Transfer-Encoding: 7bit
 
 >     Unfortunately, the example code got lost.
 >     Could you possibly send it to me privately? I will complete
 >     the PR with it.
 >     Thanks, Paolo.
 
 See attached.
 ------=_NextPart_000_0026_01C287E1.FB7F23C0
 Content-Type: application/octet-stream;
 	name="Gcc_bug.cpp"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
 	filename="Gcc_bug.cpp"
 
 
 #include <iostream>
 
 template <class T>
 struct is_const
 {
 	static void check()
 	{ std::cout << "non-const\n"; }
 };
 
 template <class T>
 struct is_const<T const>
 {
 	static void check()
 	{ std::cout << "const\n"; }
 };
 
 template <class T>
 void overload_reference(T&)
 {std::cout << "non-const\n"; }
 
 template <class T>
 void overload_reference(const volatile T&)
 {std::cout << "const\n"; }
 
 template <class T>
 void overload_pointer(T*)
 {std::cout << "non-const\n"; }
 
 template <class T>
 void overload_pointer(const volatile T*)
 {std::cout << "const\n"; }
 
 int sample_proc(int)
 {
 return 0;
 }
 
 int main()
 {
 	typedef int (foo_type)(int);
 	is_const<foo_type>::check();
 	foo_type& f = sample_proc;
 	overload_reference(f);
 	foo_type* pf = &f;
 	overload_pointer(pf);
 }
 
 
 
 ------=_NextPart_000_0026_01C287E1.FB7F23C0--
 
 
Comment 7 Kriang Lerdsuwanakij 2002-12-03 06:35:34 UTC
Responsible-Changed-From-To: unassigned->lerdsuwa
Responsible-Changed-Why: Will look at it.
Comment 8 Kriang Lerdsuwanakij 2002-12-05 06:26:19 UTC
Responsible-Changed-From-To: lerdsuwa->nathan
Responsible-Changed-Why: Hi Nathan,
    
    Awhile back you fixed a bug related to DR 295 implementation
    on the main trunk with relevant ChangeLog entry below:
    
      2002-09-16  Nathan Sidwell  <nathan@codesourcery.com>
    
            Remove DR 295 implementation.
            * pt.c (check_cv_quals_for_unify): Disable function & method cases.
            * tree.c (cp_build_qualified_type_real): Likewise. Don't warn
            about ignoring volatile qualifiers.
    
    However the bug is still present in the 3.2 branch
    and there are two GNATS report about the problem: PR8503
    and PR7774.  I've verified that the patch fixes these
    bugs.  Would you consider applying it for the 3.2 branch
    as well?
    
    --Kriang
Comment 9 Nathan Sidwell 2002-12-26 04:56:41 UTC
State-Changed-From-To: analyzed->closed
State-Changed-Why: 2002-12-26  Nathan Sidwell  <nathan@codesourcery.com>
    
    	PR c++/8503
    	Remove DR 295 implementation.
    	* pt.c (check_cv_quals_for_unify): Disable function & method cases.
    	* tree.c (cp_build_qualified_type_real): Likewise. Don't warn
    	about ignoring volatile qualifiers.
Comment 10 Nathan Sidwell 2002-12-26 12:58:07 UTC
From: nathan@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/8503
Date: 26 Dec 2002 12:58:07 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Branch: 	gcc-3_2-branch
 Changes by:	nathan@gcc.gnu.org	2002-12-26 04:58:07
 
 Modified files:
 	gcc/cp         : ChangeLog pt.c tree.c 
 	gcc/testsuite  : ChangeLog 
 	gcc/testsuite/g++.dg/template: qualttp20.C 
 	gcc/testsuite/g++.old-deja/g++.jason: report.C 
 	gcc/testsuite/g++.old-deja/g++.other: qual1.C 
 
 Log message:
 	cp:
 	PR c++/8503
 	Remove DR 295 implementation.
 	* pt.c (check_cv_quals_for_unify): Disable function & method cases.
 	* tree.c (cp_build_qualified_type_real): Likewise. Don't warn
 	about ignoring volatile qualifiers.
 	testsuite:
 	* g++.dg/template/qualttp20.C: Adjust expected errors.
 	* g++.old-deja/g++.jason/report.C: Likewise.
 	* g++.old-deja/g++.other/qual1.C: Likewise.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.2685.2.114.2.56&r2=1.2685.2.114.2.57
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.578.2.11.2.8&r2=1.578.2.11.2.9
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/tree.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.268.2.7.2.3&r2=1.268.2.7.2.4
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.1672.2.166.2.76&r2=1.1672.2.166.2.77
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/qualttp20.C.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.1&r2=1.1.12.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.old-deja/g++.jason/report.C.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.7.2.1&r2=1.7.2.1.4.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.old-deja/g++.other/qual1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.3&r2=1.3.10.1