public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/9437: template function parameter `T*' shouldn't match pointers to members
@ 2003-01-24 20:12 bangerth
0 siblings, 0 replies; 4+ messages in thread
From: bangerth @ 2003-01-24 20:12 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, martin, nobody
Synopsis: template function parameter `T*' shouldn't match pointers to members
State-Changed-From-To: open->analyzed
State-Changed-By: bangerth
State-Changed-When: Fri Jan 24 20:12:59 2003
State-Changed-Why:
Something's indeed wrong here. To see what the template
parameter matches, execute the following variation:
-------------------------
extern "C" void printf (const char *, ...);
struct S {
template <typename T>
operator T* () const {
printf ("%s\n", __PRETTY_FUNCTION__);
return static_cast<T*> (0);
}
} null;
struct A { int i; };
static void f (int A::* pmi) { }
int main () { f (null); }
-----------------------------
It displays
g/a> /home/bangerth/bin/gcc-3.4-pre/bin/c++ x.cc
g/a> ./a.out
S::operator T*() const [with T = int A::*]
But then the return type would be _pointer_ to member
pointer, not member pointer.
Confirmed with 2.95, 3.2.2, 3.3, 3.4
W.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9437
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: c++/9437: template function parameter `T*' shouldn't match pointers to members
@ 2003-01-29 11:38 nathan
0 siblings, 0 replies; 4+ messages in thread
From: nathan @ 2003-01-29 11:38 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, martin, nathan
Synopsis: template function parameter `T*' shouldn't match pointers to members
State-Changed-From-To: analyzed->closed
State-Changed-By: nathan
State-Changed-When: Wed Jan 29 11:38:49 2003
State-Changed-Why:
mainline and 3.3 branch
2003-01-28 Nathan Sidwell <nathan@codesourcery.com>
PR c++/9437
* pt.c (unify): Don't unify '*T' with 'U C::*'.
2003-01-28 Nathan Sidwell <nathan@codesourcery.com>
PR c++/9437
* g++.dg/template/unify4.C: New test.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9437
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: c++/9437: template function parameter `T*' shouldn't match pointers to members
@ 2003-01-28 17:53 nathan
0 siblings, 0 replies; 4+ messages in thread
From: nathan @ 2003-01-28 17:53 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, martin, nathan, nobody
Synopsis: template function parameter `T*' shouldn't match pointers to members
Responsible-Changed-From-To: unassigned->nathan
Responsible-Changed-By: nathan
Responsible-Changed-When: Tue Jan 28 17:53:01 2003
Responsible-Changed-Why:
mine
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9437
^ permalink raw reply [flat|nested] 4+ messages in thread
* c++/9437: template function parameter `T*' shouldn't match pointers to members
@ 2003-01-24 19:46 martin
0 siblings, 0 replies; 4+ messages in thread
From: martin @ 2003-01-24 19:46 UTC (permalink / raw)
To: gcc-gnats
>Number: 9437
>Category: c++
>Synopsis: template function parameter `T*' shouldn't match pointers to members
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: accepts-illegal
>Submitter-Id: net
>Arrival-Date: Fri Jan 24 19:46:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: Martin Buchholz
>Release: g++ (GCC) 3.3 20030122 (prerelease)
>Organization:
>Environment:
Linux x86
>Description:
The source file below should fail to compile
with something like `no conversion to int A::*',
as it does with icc and Comeau C++.
The standard is not completely clear on this, but
here is a rationale for why accepting the code is wrong:
If `T*' matches `int A::*', then what type is T??
`int A::' is not a type, and T cannot be int, since
the types `int *' and `int A::*' are very different.
A pointer to member is not a pointer.
Code:
----------------------------------------------------
struct
{
template <typename T>
operator T* () const { return static_cast<T*> (0); }
} null;
struct A { int i; };
static void f (int A::* pmi) { }
int main () { f (null); }
>How-To-Repeat:
Compile above code with `g++ null_ptr.c'.
It incorrectly compiles without warning or error.
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-01-29 11:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-24 20:12 c++/9437: template function parameter `T*' shouldn't match pointers to members bangerth
-- strict thread matches above, loose matches on Subject: below --
2003-01-29 11:38 nathan
2003-01-28 17:53 nathan
2003-01-24 19:46 martin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).