New issue 39 by be...@bigpond.net.au: Casacore doesn't build with clang/llvm
http://code.google.com/p/casacore/issues/detail?id=39
What steps will reproduce the problem?
1. Checkout casacore trunk
2. Build with clang/llvm 3.0
The attached patch fixes a number of errors and a few of the more annoying
warnings. I have verified the tests that pass when compiled with GCC still
pass with clang. One particular class of change in the patch perhaps begs
some explanation, since GCC will happily compile invalid C++ code. Take
this example code:
void f(int x)
{
std::cout << "Global" << std::endl;
}
template <typename T> struct Base {
void f(T x) {
std::cout << "Base"<< std::endl;
};
};
template <typename T> struct Derived : public Base<T> {
void work(T x) {
f(x);
}
};
int main(int argc, char *argv[])
{
Derived<int> d;
d.work(1);
}
Both GCC and clang/llvm will compile this and will print "Global". If you
remove the global f() (leaving Base::f()) then, GCC will compile it and
print "Base" while clang/llvm will report an error:
program.cc:18:5: error: use of undeclared identifier 'f'
f(x);
^
this->
program.cc:25:7: note: in instantiation of member function
'Derived<int>::work' requested here
d.work(1);
^
program.cc:11:8: note: must qualify identifier to find this declaration
in dependent base class
void f(T x) {
The required behaviour is described in the C++ standard:
"In the definition of a class template or in the definition of a member of
such a template that appears outside
of the template definition, if a base class of this template depends on a
template-parameter, the base class
scope is not examined during name lookup until the class template is
instantiated."
In the patch I have made all method calls dependent by prefixing them
with "this->"
Further info can be found here:
http://www.parashift.com/c++-faq-lite/templates.html#faq-35.19
http://www.parashift.com/c++-faq-lite/templates.html#faq-35.20
Attachments:
casacore-clang.patch 42.3 KB
Comment #1 on issue 39 by be...@bigpond.net.au: Casacore doesn't build with
clang/llvm
http://code.google.com/p/casacore/issues/detail?id=39
(No comment was entered for this change.)
Comment #2 on issue 39 by be...@bigpond.net.au: Casacore doesn't build with
clang/llvm
http://code.google.com/p/casacore/issues/detail?id=39
Revision r21159 resolves this problem.