------- Comment #2 from pinskia at gcc dot gnu dot org  2006-11-16 04:02 -------
This is not a bug.
14.6.4.2 Candidate functions
For a function call that depends on a template parameter, if the function name
is an unqualified-id but not a template-id, the candidate functions are found
using the usual look rules (3.4.1, 3.4.2) except that:
-- For the part of the lookup using unqualified name lookup (3.4.1), only
functions with external linkage from the template __DEFINITION__ context are
found
-- For the part of the lookup using associated namespaces (3.4.2), only
functions declarations with external linkage found in either the template
__DEFINITION__ context or the template __INSTANTIATION__ context are found.


__BOLD__ is mine.

So what this says that the functions that are chosen for this fn (in the first
case) is either the template fn or a function which is associated with the
namespace of the type, which is in this case is the global namespace (ADL does
not look into nested namespaces).

That explains the first case.

The second case can be explained by this:
the function fn is seen at the template __DEFINITION__ context which makes it
valid code.

The third case can be explained by this:
The namespace associated with the type is the global namespace and there is a
function fn that matches the arguments in that namespace at the template
__INSTANTIATION__ context.

Hopefully this explains why the first case is invalid code and why the rest are
valid.

One should note there is no associated namespace for fundumental types at least
not yet, there is a Defect report about this to the C++ standard raising from
DR 197.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29844

Reply via email to