------- Comment #1 from gdr at cs dot tamu dot edu 2007-08-21 00:23 ------- Subject: Re: New: C++ frontend finds static function in argument dependent lookup based on template parameter
"ian at airs dot com" <[EMAIL PROTECTED]> writes: | In the C++ standard section 14.6.4.2 [temp.dep.candidate] says this: | | " | 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 lookup rules (3.4.1, 3.4.2) except that: | | -- For the part of the lookup using unqualified name lookup (3.4.1), only | function declarations with external linkage from the template definition | context are found. | " | | If I understand this correctly, it seems to me that this code should fail to | compile: | | template<typename t> | static void f(t v) { } | | template<typename t> | void bar(t v) { f(v); } | | void quux(int i) { bar(i); } Yes, you are correct. I'm pretty sure I already opened a PR for this, but my memory is failing me. I'm pretty sure I came with an example whose meaning was changed -- in the presence of export, bug GCC does not implement export so that aspect may be a moot point. just while discussing [...] | If I'm reading the standard correctly, then this is a minor case of the C++ | frontend failing to properly diagnose an invalid C++ program. I may also silently change the semantics of a well-formed function -- imagine a case where the static function should not be part of the overload set. | I noticed this because of the Sun Studio's -features=templrefstatic option. | The existence of this option means that if we do change the compiler, we need | to provide an option to implement the existing behaviour. Perhaps we should | simply change the behaviour for -pedantic. I believe we should warn by default and have -pedantic reject the code in case the only candidate is a static function. -- Gaby -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33129