public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/7100: Class constructors considered during argument-dependent lookup
@ 2002-09-14 14:18 nathan
  0 siblings, 0 replies; 3+ messages in thread
From: nathan @ 2002-09-14 14:18 UTC (permalink / raw)
  To: david.abrahams, gcc-bugs, gcc-prs, nobody

Synopsis: Class constructors considered during argument-dependent lookup

State-Changed-From-To: open->closed
State-Changed-By: nathan
State-Changed-When: Sat Sep 14 14:18:43 2002
State-Changed-Why:
    see gaby's comment

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


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

* Re: c++/7100: Class constructors considered during argument-dependent lookup
@ 2002-06-21 13:28 Gabriel Dos Reis
  0 siblings, 0 replies; 3+ messages in thread
From: Gabriel Dos Reis @ 2002-06-21 13:28 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

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

From: Gabriel Dos Reis <gdr@codesourcery.com>
To: david.abrahams@rcn.com
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: c++/7100: Class constructors considered during argument-dependent lookup
Date: 21 Jun 2002 21:03:59 +0200

 david.abrahams@rcn.com writes:
 
 | >Number:         7100
 | >Category:       c++
 | >Synopsis:       Class constructors considered during argument-dependent lookup
 
 The data you provided are insufficient to conclude that GCC/g++ was
 considering a class constructor while performing a Koenig lookup.  See
 below. 
 
 [...]
 
 | >Description:
 | The following should compile, but fails instead with:
 
 There is no requirement in the standard that says the program should
 compile.  There are disagreement about what should happen.
 See the looong thread starting at c++std-core-8637. In
 c++std-core-8676 John Spicer recognized there is nothing in the
 standard that contradicts Bill Gibbons position.
 
 | foo.cpp: In function `int X::f(T) [with T = Z::S]':
 | foo.cpp:33:   instantiated from here
 | foo.cpp:3: `struct Z::object' is not a function,
 
 This indicates that Koenig lookup finds 'object' which is actually
 designating something that is not a function (in this case a class-name),
 not that GCC was considering class constructors.
 
 | foo.cpp:16:   conflict with `template<class T> X::o X::object(const T&)'
 | foo.cpp:26:   in call to `object'
 | >How-To-Repeat:
 | namespace Z
 | {
 |    struct object {
 |        object( char*);
 |    };
 |    struct S {};
 | }
 | 
 | namespace X
 | {
 |   struct o {};
 | 
 |   template <class T>
 |   o object(T const&);
 |   
 |   template <class T>
 |   void g(T const&);
 | 
 |   int g(o const&);
 | 
 |  template <class T>
 |  int f(T  x)
 |  {
 |      return g(object(x));
 
 What happens here with T = Z::S is that the associated namespace of T
 (::Z) contains a declaration for 'object' found by usual lookup rules
 (as indicated in the Koenig lookup rules).  Note also that
 
 3.4.3/3
   When considering an associated namespace, the lookup is the same as
   the lookup performed when the asso-ciated namespace is used as a
   qualifier (3.4.3.2) except that: 
   -- Any using-directives in the associated namespace are ignored.
   -- Any namespace-scope friend functions declared in associated
      classes are visible within their respective namespaces even if they
      are not visible during an ordinary lookup (11.4). 
 
 We are not in the exceptional cases here so the general rule applies
 and name lookup for Z::object finds a non-function declaration.
 
 At this point there is no disposition in the standard that says
 that the program should compile.  GCC chooses to do perform name
 lookup, uniformly, and then reject program if the outcome of the
 Koenig lookup contains a non-function.
 
 And finally, have a look at 
 
   http://anubis.dkuug.dk/JTC1/SC22/WG21/docs/cwg_active.html#218
 
 -- Gaby


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

* c++/7100: Class constructors considered during argument-dependent lookup
@ 2002-06-21 10:55 david.abrahams
  0 siblings, 0 replies; 3+ messages in thread
From: david.abrahams @ 2002-06-21 10:55 UTC (permalink / raw)
  To: gcc-gnats


>Number:         7100
>Category:       c++
>Synopsis:       Class constructors considered during argument-dependent lookup
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jun 21 10:46:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     david.abrahams@rcn.com
>Release:        3.1
>Organization:
>Environment:
cygwin
>Description:
The following should compile, but fails instead with:

foo.cpp: In function `int X::f(T) [with T = Z::S]':
foo.cpp:33:   instantiated from here
foo.cpp:3: `struct Z::object' is not a function,
foo.cpp:16:   conflict with `template<class T> X::o X::object(const T&)'
foo.cpp:26:   in call to `object'
>How-To-Repeat:
namespace Z
{
   struct object {
       object( char*);
   };
   struct S {};
}

namespace X
{
  struct o {};

  template <class T>
  o object(T const&);
  
  template <class T>
  void g(T const&);

  int g(o const&);

 template <class T>
 int f(T  x)
 {
     return g(object(x));
 }
}

int main()
{
   X::f(Z::S());
   return 0;
}

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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

end of thread, other threads:[~2002-09-14 21:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-14 14:18 c++/7100: Class constructors considered during argument-dependent lookup nathan
  -- strict thread matches above, loose matches on Subject: below --
2002-06-21 13:28 Gabriel Dos Reis
2002-06-21 10:55 david.abrahams

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