[LLVMbugs] [Bug 12615] New: Incorrect scope to lookup a user-defined operator called from a function template
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sat Apr 21 14:17:49 PDT 2012
http://llvm.org/bugs/show_bug.cgi?id=12615
Bug #: 12615
Summary: Incorrect scope to lookup a user-defined operator
called from a function template
Product: clang
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P
Component: Frontend
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: satanasyan at mips.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
If function template definition contains call of a user-defined operator and
the operator's argument does not depend on template parameters, clang uses
incorrect scope to lookup the operator. The scope ends at the point of the
function template instantiation not at the point of the function template
definition. Functions are looked up correctly.
$ cat test.cc
#include <stdio.h>
template <typename T>
struct A
{};
A<int> a;
template <typename T>
int operator*(T) { return 1; }
template <typename T>
int bar(T) { return 1; }
template <typename T>
void foo(T)
{
printf("bar(a): %d\n", bar(a));
printf("*a: %d\n", *a);
}
int operator*(A<int>) { return 10; }
int bar(A<int>) { return 10; }
int main()
{
foo(0);
}
% clang++ --version
clang version 3.1 (trunk 154997:154998M) (llvm/trunk 154997)
Target: i386-pc-linux-gnu
Thread model: posix
% clang++ test.cc && ./a.out
bar(a): 1
*a: 10
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list