Boost logo

Boost :

From: Boris Gubenko (Boris.Gubenko_at_[hidden])
Date: 2007-10-24 10:27:21


Markus Schoepflin wrote:
> Hmm, have a look at this:
>
> ---%<---
> template <class T> struct foo {
> void bar() { foobar(); }
> };
>
> void foobar() {}
>
> void argl() {
> foo<int> f;
> f.bar();
> }

According to EDG documentation:

 "
 The dependent name lookup rules require that nondependent names be
 looked up at the point of use in the template definition, and that
 overload resolution be performed on nondependent calls at that point.
 "

Based on the above, I think that EDG is correct in rejecting this
program when dependent name lookup is enabled (it is automatically
enabled in strict mode) because at the point of use in the template
definition of foo, foobar is not visible.

cxxosf.zko.hp.com> eccp -c x.cpp
cxxosf.zko.hp.com> eccp -c x.cpp --dep_name
"x.cpp", line 2: error: identifier "foobar" is undefined
     void bar() { foobar(); }
                  ^

1 error detected in the compilation of "x.cpp".
cxxosf.zko.hp.com>

Boris

----- Original Message -----
From: "Markus Schöpflin" <markus.schoepflin_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Wednesday, October 24, 2007 9:01 AM
Subject: Re: [boost] [interprocess] Problematic interface for intrusive_ptr

Peter Dimov wrote:
> Markus Schöpflin wrote:
>> Hello,
>>
>> as part of its interface intrusive_ptr requires the user to supply two
>> functions:
>>
>> void intrusive_ptr_add_ref(T * p);
>> void intrusive_ptr_release(T * p);
>>
>> These are called from within the implementation of the intrusive_ptr
>> class. When compiling intrusive_ptr_test, cxx complains that
>> intrusive_ptr uses undeclared functions, because the test includes
>> the header file for intrusive_ptr before declaring those two
>> functions.
>
> Are you sure that the compiler is correct? A dependent unqualified call is
> resolved at instantiation time.

Hmm, have a look at this:

---%<---
template <class T> struct foo {
   void bar() { foobar(); }
};

void foobar() {}

void argl() {
   foo<int> f;
   f.bar();
}
--->%---

Comeau Online has this to say:

---%<---
"ComeauTest.c", line 2: error: identifier "foobar" is undefined
     void bar() { foobar(); }
                  ^

1 error detected in the compilation of "ComeauTest.c".
--->%---

What do you think?

Markus

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk