Opened 13 years ago
Closed 12 years ago
#3645 closed Bugs (fixed)
iterator_facade does not work in presence of ::implicit_cast
Reported by: | 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)
Change History (11)
by , 13 years ago
Attachment: | minimal_boost.cc added |
---|
by , 13 years ago
Attachment: | minimal_no_boost.cc added |
---|
Minimal test case without boost demonstrating compilation errors
by , 13 years ago
Attachment: | iterator_facade.patch added |
---|
Patch (qualify call to implicit_cast in iterator_facade.hpp)
comment:1 by , 13 years ago
Cc: | added |
---|
comment:2 by , 13 years ago
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 by , 13 years ago
Component: | None → iterator |
---|---|
Owner: | set to |
comment:4 by , 13 years ago
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 by , 13 years ago
Cc: | added |
---|
comment:6 by , 12 years ago
Owner: | changed from | to
---|
comment:7 by , 12 years ago
Patch applied in revision [67738]; will wait for tests to cycle before merging to release branch.
comment:8 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Fix merged to release branch in [67792]
Minimal test case demonstrating compilation errors