public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/3831: problem with forward declaration of function taking a reference to a generic member
@ 2001-08-01  5:39 nathan
  0 siblings, 0 replies; 4+ messages in thread
From: nathan @ 2001-08-01  5:39 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, lachaume, nobody

Synopsis: problem with forward declaration of function taking a reference to a generic member

State-Changed-From-To: open->analyzed
State-Changed-By: nathan
State-Changed-When: Wed Aug  1 05:39:51 2001
State-Changed-Why:
    confirmed as a bug

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=3831&database=gcc


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: c++/3831: problem with forward declaration of function taking a reference to a generic member
@ 2003-05-01 17:08 giovannibajo
  0 siblings, 0 replies; 4+ messages in thread
From: giovannibajo @ 2003-05-01 17:08 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, lachaume, nobody

Synopsis: problem with forward declaration of function taking a reference to a generic member

State-Changed-From-To: analyzed->closed
State-Changed-By: bajo
State-Changed-When: Thu May  1 17:08:14 2003
State-Changed-Why:
    Your code is ill-formed, because the functions should be
    declared/defined as:
    
    template <typename u, typename v> void g(typename A<u>::template B<v>&);
    
    Doing this, with 3.4 (and previous versions) the code works
    as expected.
    
    The ambigous overload bug can't be reproduced with legal
    code. Even if I could, it's gone in 3.4 for sure (it was
    caused by bugs in the implicit typename/template code which
    does not exist anymore), it is not a regression, so the bug
    report would be closed as "fixed in 3.4" for sure.
    
    I cannot reproduce the bug about the missing const
    qualifier with 3.4. I will try harder but that's the only
    thing we could save of this report. If I succeed at it, I
    will file a new PR.
    
    Thanks for your report.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=3831


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: c++/3831: problem with forward declaration of function taking a reference to a generic member
@ 2003-01-03 13:36 Nathanael Nerode
  0 siblings, 0 replies; 4+ messages in thread
From: Nathanael Nerode @ 2003-01-03 13:36 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/3831; it has been noted by GNATS.

From: Nathanael Nerode <neroden@twcny.rr.com>
To: gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org,
   lachaume@laog.obs.ujf.grenoble.fr, gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org
Cc:  
Subject: Re: c++/3831: problem with forward declaration of function taking a reference to a generic member
Date: Fri, 3 Jan 2003 08:26:34 -0500

 3.4 behaves totally differently on the examples.
 
 I believe the stated problem is fixed.  However, I need to verify that the 
 two changes I made to the examples to get them to work are, in fact, fixes 
 needed to make the code legal.  (If not, I have revealed other bugs...)
 
 If the definition of struct A is moved above the forward declaration of g, 
 and the use of 'typename' inside the formal arguments is removed in all 
 cases, all is well.
 --
 template <typename u> struct A;
 
 template <typename u> struct A {
     template <typename v> struct B { };
  };
  
 template <typename u, typename v> void g(A<u>::B<v>&);
 
 template <typename u, typename v> void g(A<u>::B<v>&);
   
 int main() {
     A<int>::B<float> b;
     g<int, float>(b);
  }
 --
 
 I believe that the definition of struct A needs to be above the declaration 
 of g because otherwise B isn't declared at the time of declaration of g.  I 
 can't figure out a way to declare B before the definition of A.  If there is 
 one in the C++ standard, I'll be happy to use it and see if that works.
 
 I don't know why the 'typename' has to be removed from inside the arguments.
 But it it isn't removed, g++ 3.4 does the same thing as it does if B isn't 
 declared before g: it decides that g is not a function (calls it a "variable 
 or field").
 
 --Nathanael


^ permalink raw reply	[flat|nested] 4+ messages in thread

* c++/3831: problem with forward declaration of function taking a reference to a generic member
@ 2001-07-26  5:56 lachaume
  0 siblings, 0 replies; 4+ messages in thread
From: lachaume @ 2001-07-26  5:56 UTC (permalink / raw)
  To: gcc-gnats

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 4905 bytes --]

>Number:         3831
>Category:       c++
>Synopsis:       problem with forward declaration of function taking a reference to a generic member
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Thu Jul 26 05:56:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Régis Lachaume
>Release:        3.0 (release) and prior versions
>Organization:
>Environment:
gag237:cpp/bug $ uname -a
Linux gag237 2.4.0-test10 #3 mer déc 6 11:59:57 CET 2000 i686 unknown
gag237:cpp/bug $ ~/linux/bin/g++ -v
Reading specs from /gagax6/ur3/lachaume/linux/lib/gcc-lib/i686-pc-linux-gnu/3.0/specs
Configured with: ../configure --prefix=/gagax6/ur3/lachaume/indep --exec-prefix=/gagax6/ur3/lachaume/linux --enable-languages=c,c++ : (reconfigured) ../configure --prefix=/gagax6/ur3/lachaume/indep --exec-prefix=/gagax6/ur3/lachaume/linux --enable-languages=c++ --with-gxx-include-dir=/gagax6/ur3/lachaume/indep/include/g++ --with-local-prefix=/gagax6/ur3/lachaume/indep/
Thread model: single
gcc version 3.0
gag237:cpp/bug $ g++ -v
Reading specs from /usr/lib/gcc-lib/i586-mandrake-linux/2.95.3/specs
gcc version 2.95.3 19991030 (prerelease)
gag237:cpp/bug $ 
>Description:
g++ considers the forward declaration of a function taking a reference to a generic member and the definition of this function as two different declarations.
It issues the error ``call of overloaded ... is ambiguous''.

Example with g++ 2.95.3, bug also reproduced with g++ 3.0

gag237:cpp/bug $ more typename-light.cpp 
template <typename u> struct A;
template <typename u, typename v> void g(typename A<u>::B<v>&);

template <typename u> struct A {
   template <typename v> struct B { };
};

template <typename u, typename v> void g(typename A<u>::B<v>&);

int main() {
   A<int>::B<float> b;
   g<int, float>(b);
}
gag237:cpp/bug $ g++ -Wall -ansi -pedantic -W -O2 typename-light.cpp
typename-light.cpp: In function `int main()':
typename-light.cpp:12: call of overloaded `g (A<int>::B<float> &)' is ambiguous
typename-light.cpp:2: candidates are: void g<int, float>(A<int>::B<float> &)
typename-light.cpp:8:                 void g<int, float>(A<int>::B<float> &)
gag237:cpp/bug $ g++ --version
2.95.3
gag237:cpp/bug $ ~//linux/bin/g++ -Wall -W -ansi -pedantic -O2 -static -I/gagax6/ur3/lachaume/indep/include/g++-3.0 -I/gagax6/ur3/lachaume/indep/include/g++-3.0/i686-pc-linux-gnu/ -o typename typename.cpp
typename.cpp: In function `int main()':
typename.cpp:26: call of overloaded `g(A<int>::B<float>&)' is ambiguous
typename.cpp:13: candidates are: void g(typename A<u>::B<v>&) [with u = int, v 
   = float]
typename.cpp:20:                 void g(A<u>::B<v>&) [with u = int, v = float]
typename.cpp:27: call of overloaded `h(A<int>::B<float>&)' is ambiguous
typename.cpp:14: candidates are: void h(typename A<u>::B<v>&) [with u = int, v 
   = float]
typename.cpp:21:                 void h(const A<u>::B<v>&) [with u = int, v = 
   float]
gag237:cpp/bug $ ~/linux/bin/g++ --version
3.0
gag237:cpp/bug $

Other problems: 
* a missing typenames in the definition is not diagnosed with the -pedantic option.
* g++ v >= 3.0 ignores an eventual const qualifier in the forward declaration when reporting the error, whereas g++ 2.95.3 does it correctly

A full example file is attached.
>How-To-Repeat:

>Fix:
No idea.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="typename.cpp"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="typename.cpp"

Ly8gZm9yd2FyZCBkZWNsYXJhdGlvbiBvZiBhIGZ1bmN0aW9uIHRha2luZyBhIGdlbmVyaWMgbWVt
YmVyCgovLyBQcm9ibGVtcyB3aXRoIGdjYyAzLjAKLy8gICAxLiBlcnJvciBgYGFtYmlndW91cyBv
dmVybG9hZGVkIC4uLicnCi8vICAgMi4gbm8gd2FybmluZyB3aXRoIG1pc3NpbmcgdHlwZW5hbWUg
aW4gZGVmaW5pdGlvbiBvZiBrICgtcGVkYW50aWMpCi8vICAgMy4gaW4gZXJyb3IgcmVwb3J0IHRo
ZSBjb25zdCBxdWFsaWZpZXIgb2YgaCBpcyBzdXJwaXNpbmdseSBkaXNjYXJkZWQKLy8gUHJvYmxl
bXMgd2l0aCBnY2MgMi45NS4zCi8vICAgLSBQcm9ibGVtcyAxLiAmIDIuIG9jY3VyLgovLyAgIC0g
Y29uc3QgcXVhbGlmaWVyIGluIGggY29ycmVjdGx5IGFwcGVhcnMgaW4gdGhlIGVycm9yIG1lc3Nh
Z2UKCgp0ZW1wbGF0ZSA8dHlwZW5hbWUgdT4gc3RydWN0IEE7CnRlbXBsYXRlIDx0eXBlbmFtZSB1
LCB0eXBlbmFtZSB2PiB2b2lkIGcodHlwZW5hbWUgQTx1Pjo6Qjx2PiYpOwp0ZW1wbGF0ZSA8dHlw
ZW5hbWUgdSwgdHlwZW5hbWUgdj4gdm9pZCBoKGNvbnN0IHR5cGVuYW1lIEE8dT46OkI8dj4mKTsK
CnRlbXBsYXRlIDx0eXBlbmFtZSB1PiBzdHJ1Y3QgQSB7CiAgIHRlbXBsYXRlIDx0eXBlbmFtZSB2
PiBzdHJ1Y3QgQiB7IH07Cn07Cgp0ZW1wbGF0ZSA8dHlwZW5hbWUgdSwgdHlwZW5hbWUgdj4gdm9p
ZCBnKHR5cGVuYW1lIEE8dT46OkI8dj4mKSB7IH0KdGVtcGxhdGUgPHR5cGVuYW1lIHUsIHR5cGVu
YW1lIHY+IHZvaWQgaChjb25zdCB0eXBlbmFtZSBBPHU+OjpCPHY+JikgeyB9CnRlbXBsYXRlIDx0
eXBlbmFtZSB1LCB0eXBlbmFtZSB2PiB2b2lkIGsoY29uc3QgQTx1Pjo6Qjx2PiYpIHsgfQoKaW50
IG1haW4oKSB7CiAgIEE8aW50Pjo6QjxmbG9hdD4gYjsKICAgZzxpbnQsIGZsb2F0PihiKTsKICAg
aDxpbnQsIGZsb2F0PihiKTsKfQo=


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-05-01 17:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-01  5:39 c++/3831: problem with forward declaration of function taking a reference to a generic member nathan
  -- strict thread matches above, loose matches on Subject: below --
2003-05-01 17:08 giovannibajo
2003-01-03 13:36 Nathanael Nerode
2001-07-26  5:56 lachaume

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).