Vector Class Discussion

 
thread Compilation errors with LLVM - Ilja Honkonen - 2014-10-21
last reply Compilation errors with LLVM - Agner - 2014-10-22
 
Compilation errors with LLVM
Author:  Date: 2014-10-21 19:01
Hello

Vectorclass fails to compile due to an ambiguous call to one of two constructors in a few places. First error:

/Users/iljah/libraries/vectorclass/vectorf128.h:224:22: error: ambiguous conversion for functional-style cast from
'const Vec4fb' to 'Vec4ib'
return Vec4fb( ! Vec4ib(a));
-------------------^~~~~~~~
/Users/iljah/libraries/vectorclass/vectori128.h:2023:7: note: candidate is the implicit move constructor
class Vec4ib : public Vec4i {
------^
/Users/iljah/libraries/vectorclass/vectori128.h:2023:7: note: candidate is the implicit copy constructor
/Users/iljah/libraries/vectorclass/vectori128.h:2033:5: note: candidate constructor
Vec4ib(__m128i const & x) {
----^


Looking at the code the compiler (Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn)) seems right as Vec4i has this constructor:

Vec4i(__m128i const & x) {
xmm = x;
}

and Vec4ib has the same constructor:

Vec4ib(__m128i const & x) {
xmm = x;
}

and since 4ib inherits 4i it now has two identical constructors. One answer to this type of situation (https://stackoverflow.com/questions/3156597/override-or-remove-an-inherited-constructor) on stackoverflow was "In general - if you have a need to remove inherited constructor, then you probably need to rethink/redesign your class hierarchy." Does 4ib really need to inherit from 4i? Doesn't seem like it would be that much code to duplicate for 4ib to inherit directly from 128b, at least until a better solution is found.

   
Compilation errors with LLVM
Author: Agner Date: 2014-10-22 00:07
It's a problem in the Clang compiler.

Please change line 134 in the file vectorf128h from

#if defined (__clang__) && CLANG_VERSION < 30500
to
#if defined (__clang__) && CLANG_VERSION < 30900
I expected them to fix this bug in Clang version 3.5 but it is not fixed yet.

The bug report is here.