Modify

Ticket #3645 (closed Bugs: fixed)

Opened 4 years ago

Last modified 3 years ago

iterator_facade does not work in presence of ::implicit_cast

Reported by: romanp@… Owned by: marshall
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

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

Change History

Changed 4 years ago by romanp@…

Minimal test case demonstrating compilation errors

Changed 4 years ago by romanp@…

Minimal test case without boost demonstrating compilation errors

Changed 4 years ago by romanp@…

Patch (qualify call to implicit_cast in iterator_facade.hpp)

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

  • Cc roman.perepelitsa@… added

comment:2 Changed 4 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 4 years ago by steven_watanabe

  • Owner set to dave
  • Component changed from None to iterator

comment:4 Changed 4 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 4 years ago by Jeffrey Yasskin <jyasskin@…>

  • Cc jyasskin@… added

comment:6 Changed 3 years ago by marshall

  • Owner changed from dave to marshall

comment:7 Changed 3 years ago by marshall

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

comment:8 Changed 3 years ago by marshall

  • Status changed from new to closed
  • Resolution set to fixed

Fix merged to release branch in [67792]

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


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

 
Note: See TracTickets for help on using tickets.