public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: lachaume@laog.obs.ujf.grenoble.fr
To: gcc-gnats@gcc.gnu.org
Subject: c++/3831: problem with forward declaration of function taking a reference to a generic member
Date: Thu, 26 Jul 2001 05:56:00 -0000	[thread overview]
Message-ID: <20010726124543.20737.qmail@sourceware.cygnus.com> (raw)

[-- 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"

Ly8gZm9yd2FyZCBkZWNsYXJhdGlvbiBvZiBhIGZ1bmN0aW9uIHRha2luZyBhIG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bmFtZSB2PiB2b2lkIGsoY29uc3QgQTx1Pjo6Qjx2PiYpIHsgfQoKaW50
IG1haW4oKSB7CiAgIEE8aW50Pjo6QjxmbG9hdD4gYjsKICAgZzxpbnQsIGZsb2F0PihiKTsKICAg
aDxpbnQsIGZsb2F0PihiKTsKfQo=


             reply	other threads:[~2001-07-26  5:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-26  5:56 lachaume [this message]
2001-08-01  5:39 nathan
2003-01-03 13:36 Nathanael Nerode
2003-05-01 17:08 giovannibajo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010726124543.20737.qmail@sourceware.cygnus.com \
    --to=lachaume@laog.obs.ujf.grenoble.fr \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).