> I don't see anything which says that a qualified name > like ::bar can become dependent because of the function > arguments. In C++03, the section 14.6.2 is written differently: In an expression of the form: postfix-expression ( expression-listopt ) where the postfix-expression is an identifier, the identifier denotes a dependent name if and only if any of the expressions in the expression-list is a type-dependent expression (14.6.2.2). That's the current standard (ignoring the incomplete C++0x), so a function call with a dependent argument is itself dependent, however, the folks at Stack Overflow have pointed out to me that being dependent is not enough, because qualified, dependent function call names can often be resolved during template parsing, irregardless of whether an argument to the function is delayed until template instantiation. The function call must also be an unqualified name to be resolved at the point of template instantiation (rather than during template parsing). I confess, that design choice in C++ makes zero sense to me but a workaround based on defining a dummy function does solve my problem. The workaround is to have a using statement to avoid qualifying the function call. Instead of: ::bar(tt) I do: using ::bar; bar(tt); And also there has to be a dummy ::bar() function defined somewhere before the template definition to keep the using statement from being an error. But the dummy function is never called, it only exists to force C++ into the correct parsing context with the using statement. If you can think of a better solution, I'd love to hear it. Ugly. C++ template fail. (But it works.) Thanks, =Shawn Yarbrough On Mon, Oct 18, 2010 at 2:41 PM, Ian Lance Taylor <iant@xxxxxxxxxx> wrote: > Shawn Yarbrough <shawn.yarbrough@xxxxxxxxx> writes: > >> Code sample below. I believe this is a gcc compiler bug because line >> 16 gives an error "has not been declared" when the function call in >> question is clearly dependent on the template parameter and therefore >> logically shouldn't be declared until template instantiation. >> >> Section 14.6.2 of the Standard and section C.13.8.1 of Stroustrup seem >> to agree with me, for example from the latter: "Basically, the name of >> a function called is dependent if it is obviously dependent by looking >> at its arguments or at its formal parameters." > > Sectoin 14.6.2 seems pretty clear in saying that this is only when the > expression is an unqualified ID. You wrote > ::bar(tt); > and ::bar is not an unqualified ID. > > In an expression of the form: > postfix-expression ( expression-listopt ) > where the postfix-expression is an unqualified-id but not a > template-id, the unqualified-id denotes a dependent name if and only > if any of the expressions in the expression-list is a type-dependent > expression (14.6.2.2). > > I don't see anything which says that a qualified name like ::bar can > become dependent because of the function arguments. > > Ian >