[LLVMbugs] [Bug 669] NEW: Reject valid C++ code, when overloaded operator() is called from a template member function
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Wed Nov 23 03:35:47 PST 2005
http://llvm.cs.uiuc.edu/bugs/show_bug.cgi?id=669
Summary: Reject valid C++ code, when overloaded operator() is
called from a template member function
Product: tools
Version: 1.6
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: llvm-g++
AssignedTo: unassignedbugs at nondot.org
ReportedBy: szalai at mm.bme.hu
llvm-g++ v1.6, rejects the following testcase, while g++ 4.0.2, icc 9.0 and sun
studio 10, accept it:
template<class T> class foo {
private:
T a;
public:
foo() : a(0) { }
T operator() ( int j ) { return a*j; }
};
class other {
private:
foo<int> foo_inst;
public:
template<bool trans> int something()
{ if(trans) return foo_inst(1); else return foo_inst(2); }
};
int main()
{
other temp;
return temp.something<true>();
}
$ llvm-g++ test-broken-1.cpp
test-broken-1.cpp: In member function `int other::something()':
test-broken-1.cpp:14: error: call to non-function `other::foo_inst'
test-broken-1.cpp:14: error: call to non-function `other::foo_inst'
The code is working if the template is not a member function of a class, just a
simple function. It also works, when the overloaded operator is referenced from
the "this" pointer.
- { if(trans) return foo_inst(1); else return foo_inst(2); }
+ { if(trans) return this->foo_inst(1); else return this->foo_inst(2); }
I have not checked with other overloaded operators, so they might fail too.
I hope that this bug will be automatically resolved using a newer version of
the gcc frontend, e.g., gcc-4.0.
Best wishes,
Robert
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
More information about the llvm-bugs
mailing list