Modify

Opened 8 years ago

Closed 7 years ago

#3645 closed Bugs (fixed)

iterator_facade does not work in presence of ::implicit_cast

Reported by: romanp@… Owned by: Marshall Clow
Milestone: Boost 1.42.0 Component: iterator
Version: Boost 1.41.0 Severity: Problem
Keywords: iterator_facade Cc: romanp@…, roman.perepelitsa@…, jyasskin@…

Description

iterator_facade does not compile if there is a function template named implicit_cast in global namespace and Value template argument of iterator_facade is a type from global namespace.

Minimal test case is attached (minimal_boost.cc). I also reduced it to something that does not use boost (minimal_no_boost.cc).

Reproducible with Comeau 4.3.0.1, gcc 4.4.0 and Clang, but *not* with gcc 4.3.1.

I'm also attaching a patch (one line -- qualify call to implicit_cast in iterator_facade.hpp).

Attachments (3)

minimal_boost.cc (419 bytes) - added by romanp@… 8 years ago.
Minimal test case demonstrating compilation errors
minimal_no_boost.cc (168 bytes) - added by romanp@… 8 years ago.
Minimal test case without boost demonstrating compilation errors
iterator_facade.patch (365 bytes) - added by romanp@… 8 years ago.
Patch (qualify call to implicit_cast in iterator_facade.hpp)

Download all attachments as: .zip

Change History (11)

Changed 8 years ago by romanp@…

Attachment: minimal_boost.cc added

Minimal test case demonstrating compilation errors

Changed 8 years ago by romanp@…

Attachment: minimal_no_boost.cc added

Minimal test case without boost demonstrating compilation errors

Changed 8 years ago by romanp@…

Attachment: iterator_facade.patch added

Patch (qualify call to implicit_cast in iterator_facade.hpp)

comment:1 Changed 8 years ago by roman.perepelitsa@…

Cc: roman.perepelitsa@… added

comment:2 Changed 8 years ago by romanp@…

The compiler is right to complain about ambiguity.

14.8.1 - Explicit template argument specification [temp.arg.explicit]

-6- [Note: For simple function names, argument dependent lookup (basic.lookup.koenig) applies even when the function name is not visible within the scope of the call. This is because the call still has the syntactic form of a function call (basic.lookup.unqual). But when a function template with explicit template arguments is used, the call does not have the correct syntactic form unless there is a function template with that name visible at the point of the call. If no such name is visible, the call is not syntactically well-formed and argument-dependent lookup does not apply. If some such name is visible, argument dependent lookup applies and additional function templates may be found in other namespaces. [Example:

namespace A {

struct B { }; template<int X> void f(B);

} namespace C {

template<class T> void f(T t);

} void g(A::B b) {

f<3>(b); ill-formed: not a function call A::f<3>(b); well-formed C::f<3>(b); ill-formed; argument dependent lookup

only applies to unqualified names

using C::f; f<3>(b); well-formed because C::f is visible; then

A::f is found by argument dependent lookup

}

--- end example] --- end note]

Which means that iterator_facade has unintended point of extension (ADL enabled call).

comment:3 Changed 8 years ago by Steven Watanabe

Component: Noneiterator
Owner: set to Dave Abrahams

comment:4 Changed 8 years ago by romanp@…

David, could you take a look?

In Google, we had to patch boost locally. It would be great to push the fix upstream.

comment:5 Changed 8 years ago by Jeffrey Yasskin <jyasskin@…>

Cc: jyasskin@… added

comment:6 Changed 7 years ago by Marshall Clow

Owner: changed from Dave Abrahams to Marshall Clow

comment:7 Changed 7 years ago by Marshall Clow

Patch applied in revision [67738]; will wait for tests to cycle before merging to release branch.

comment:8 Changed 7 years ago by Marshall Clow

Resolution: fixed
Status: newclosed

Fix merged to release branch in [67792]

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Marshall Clow.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.